Sinled / foundry-permalinks

Link to your Foundry journal entries, actors, and items from outside Foundry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FoundryVTT Permalinks

Manifest URL

TL;DR: When you open a window that can have a permalink generated, the window's URL is replaced with the link. Clicking the "Copy document id" link copies the permalink to the clipboard if possible, rather than the ID.

Supported versions: Requires Foundry 10 to work.

Developed for Meadiocrity Mead and Battlemage Brewery in Vista, CA.

Changelog

  • v1.0.5: Fix issue where settings would not load on game launch.
  • v1.0.4: Add settings: useSlugs (scope world, default true) and overrideCopyId (scope user, default true). These let you tune whether slugs should be enabled on a world basis, and whether individual users should default to the existing behavior of copying the ID instead of the permalink.
  • v1.0.3: Increase max slug length to 48
  • v1.0.2: Add slugs
  • v1.0.1: Increase reliability of generating links
  • v1.0.0: Initial release

Known issues

Login trashes the permalink. :-(

Unfortunately, I can't run code on the login page. I try to detect if the referring page had a permalink in it though - unfortunately all query parameters are thrown out on the redirect from /game to /join. This will require a Foundry VTT backend change to fix.

Workaround if you're using nginx

If you're running a reverse proxy in front of Foundry, we can make it work. The essence of the config is the following:

location / {
        proxy_pass http://localhost:30000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
}
location /game {
        proxy_pass http://localhost:30000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        # If we're returning a 302 auth redirect from /game, pass the args
        proxy_intercept_errors on;
        error_page 302 = @join_redirect;
}
location @join_redirect {
        return 302 /join$is_args$args;
}

Or, a full NixOS config:

virtualHosts."foundry.example.com" = {
  http2 = true;
  enableACME = true;
  forceSSL = true;
  locations."/" = {
    proxyPass = "http://127.0.0.1:30000";
    proxyWebsockets = true;
  };
  locations."/game" = {
    proxyPass = "http://127.0.0.1:30000";
    proxyWebsockets = true;
    extraConfig = ''
      # If we're returning a 302 auth redirect from /game, pass the args
      proxy_intercept_errors on;
      error_page 302 = @join_redirect;
    '';
  };
  extraConfig = ''
    location @join_redirect {
      return 302 /join$is_args$args;
    }
  '';
};

About

Link to your Foundry journal entries, actors, and items from outside Foundry

License:GNU General Public License v3.0


Languages

Language:TypeScript 95.5%Language:Nix 4.5%