diff --git a/CHANGELOG b/CHANGELOG index 3f3d75f..6ea3d1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ Revision history for Lutim - Add CLI command to remove images - Add CLI command to search images based on the uploader's IP address - Add .zip file check in the tests + - Allow to use a fixed domain 0.10.4 2018-05-07 - Fix bug in cache system that would allow someone to view an image with an incorrect decryption key diff --git a/lib/Lutim/Plugin/Helpers.pm b/lib/Lutim/Plugin/Helpers.pm index 8b3bcab..3382b66 100644 --- a/lib/Lutim/Plugin/Helpers.pm +++ b/lib/Lutim/Plugin/Helpers.pm @@ -51,6 +51,7 @@ sub register { $app->helper(decrypt => \&_decrypt); $app->helper(delete_image => \&_delete_image); $app->helper(iso639_native_name => \&_iso639_native_name); + $app->helper(prefix => \&_prefix); } sub _pg { @@ -321,4 +322,15 @@ sub _iso639_native_name { return ucfirst(decode 'UTF-8', get_iso639_1(shift)->{nativeName}); } +sub _prefix { + my $c = shift; + + my $prefix = $c->url_for('/')->to_abs; + # Forced domain + $prefix->host($c->config('fixed_domain')) if (defined($c->config('fixed_domain')) && $c->config('fixed_domain') ne ''); + # Hack for prefix (subdir) handling + $prefix .= '/' unless ($prefix =~ m#/$#); + return $prefix; +} + 1; diff --git a/lutim.conf.template b/lutim.conf.template index ca78c30..abf3955 100644 --- a/lutim.conf.template +++ b/lutim.conf.template @@ -236,6 +236,10 @@ # optional, default is '1; mode=block' #x_xss_protection => '1; mode=block', + # if set, the uploaded images will use this domain + # optional + #fixed_domain => 'example.org', + ########################## # Lutim cron jobs settings ########################## diff --git a/themes/default/lib/Lutim/I18N/lutim.pot b/themes/default/lib/Lutim/I18N/lutim.pot index 547c247..1452c66 100644 --- a/themes/default/lib/Lutim/I18N/lutim.pot +++ b/themes/default/lib/Lutim/I18N/lutim.pot @@ -19,7 +19,7 @@ msgstr "" #. (30) #. ($delay) #. (config('max_delay') -#: lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:161 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:178 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/for_my_delay.html.ep:14 themes/default/templates/partial/for_my_delay.html.ep:4 themes/default/templates/partial/lutim.js.ep:140 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/lutim.js.ep:150 +#: lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:161 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:178 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/for_my_delay.html.ep:14 themes/default/templates/partial/for_my_delay.html.ep:4 themes/default/templates/partial/lutim.js.ep:140 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/lutim.js.ep:150 themes/default/templates/partial/raw.js.ep:23 themes/default/templates/partial/raw.js.ep:24 themes/default/templates/partial/raw.js.ep:6 themes/default/templates/partial/raw.js.ep:7 themes/default/templates/raw.html.ep:8 themes/default/templates/raw.html.ep:9 msgid "%1 days" msgstr "" @@ -32,11 +32,11 @@ msgstr "" msgid "-or-" msgstr "" -#: lib/Lutim.pm:221 lib/Lutim/Command/cron/stats.pm:149 lib/Lutim/Command/cron/stats.pm:163 lib/Lutim/Command/cron/stats.pm:180 themes/default/templates/index.html.ep:5 +#: lib/Lutim.pm:221 lib/Lutim/Command/cron/stats.pm:149 lib/Lutim/Command/cron/stats.pm:163 lib/Lutim/Command/cron/stats.pm:180 themes/default/templates/index.html.ep:5 themes/default/templates/partial/raw.js.ep:25 themes/default/templates/partial/raw.js.ep:8 themes/default/templates/raw.html.ep:10 msgid "1 year" msgstr "" -#: lib/Lutim.pm:220 lib/Lutim/Command/cron/stats.pm:146 lib/Lutim/Command/cron/stats.pm:160 lib/Lutim/Command/cron/stats.pm:177 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:149 +#: lib/Lutim.pm:220 lib/Lutim/Command/cron/stats.pm:146 lib/Lutim/Command/cron/stats.pm:160 lib/Lutim/Command/cron/stats.pm:177 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:149 themes/default/templates/partial/raw.js.ep:22 themes/default/templates/partial/raw.js.ep:5 themes/default/templates/raw.html.ep:7 msgid "24 hours" msgstr "" @@ -48,7 +48,7 @@ msgstr "" msgid "About" msgstr "" -#: lib/Lutim/Command/cron/stats.pm:142 +#: lib/Lutim/Command/cron/stats.pm:142 themes/default/templates/raw.html.ep:3 msgid "Active images" msgstr "" @@ -104,11 +104,11 @@ msgstr "" msgid "Delete at first view?" msgstr "" -#: lib/Lutim/Command/cron/stats.pm:143 +#: lib/Lutim/Command/cron/stats.pm:143 themes/default/templates/raw.html.ep:4 msgid "Deleted images" msgstr "" -#: lib/Lutim/Command/cron/stats.pm:144 +#: lib/Lutim/Command/cron/stats.pm:144 themes/default/templates/raw.html.ep:5 msgid "Deleted images in 30 days" msgstr "" @@ -196,7 +196,7 @@ msgstr "" msgid "Image URL" msgstr "" -#: lib/Lutim/Command/cron/stats.pm:141 +#: lib/Lutim/Command/cron/stats.pm:141 themes/default/templates/raw.html.ep:2 msgid "Image delay" msgstr "" @@ -413,7 +413,7 @@ msgstr "" msgid "Toggle navigation" msgstr "" -#: lib/Lutim/Command/cron/stats.pm:150 +#: lib/Lutim/Command/cron/stats.pm:150 themes/default/templates/raw.html.ep:11 msgid "Total" msgstr "" @@ -430,7 +430,7 @@ msgstr "" msgid "Unable to find the image %1." msgstr "" -#: lib/Lutim/Controller.pm:572 lib/Lutim/Controller.pm:617 lib/Lutim/Controller.pm:656 lib/Lutim/Controller.pm:699 lib/Lutim/Controller.pm:711 lib/Lutim/Controller.pm:722 lib/Lutim/Controller.pm:749 lib/Lutim/Plugin/Helpers.pm:87 +#: lib/Lutim/Controller.pm:572 lib/Lutim/Controller.pm:617 lib/Lutim/Controller.pm:656 lib/Lutim/Controller.pm:699 lib/Lutim/Controller.pm:711 lib/Lutim/Controller.pm:722 lib/Lutim/Controller.pm:749 lib/Lutim/Plugin/Helpers.pm:88 msgid "Unable to find the image: it has been deleted." msgstr "" @@ -455,7 +455,7 @@ msgid "Uploaded files by days" msgstr "" #. ($c->app->config('contact') -#: lib/Lutim/Plugin/Helpers.pm:220 +#: lib/Lutim/Plugin/Helpers.pm:221 msgid "Uploading is currently disabled, please try later or contact the administrator (%1)." msgstr "" @@ -507,7 +507,7 @@ msgstr "" msgid "core developer" msgstr "" -#: lib/Lutim.pm:219 lib/Lutim/Command/cron/stats.pm:145 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:3 +#: lib/Lutim.pm:219 lib/Lutim/Command/cron/stats.pm:145 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:3 themes/default/templates/partial/raw.js.ep:21 themes/default/templates/partial/raw.js.ep:4 themes/default/templates/raw.html.ep:6 msgid "no time limit" msgstr "" diff --git a/themes/default/templates/partial/common.js.ep b/themes/default/templates/partial/common.js.ep index c935262..7667cd2 100644 --- a/themes/default/templates/partial/common.js.ep +++ b/themes/default/templates/partial/common.js.ep @@ -1,6 +1,6 @@ % # vim:set sw=4 ts=4 sts=4 ft=javascript expandtab: -window.gallery_url = '<%= url_for('gallery')->to_abs %>#'; -window.zip_url = '<%= url_for('zip')->to_abs %>?i='; +window.gallery_url = '<%= prefix().'gallery' %>#'; +window.zip_url = '<%= prefix().'zip' %>?i='; window.short_hash = {}; window.zip_hash = {}; function addToShortHash(short) { @@ -173,7 +173,7 @@ function link(url, dl, token, modify, only_url) { } else if (dl !== '') { url = url+'?'+dl; } - return '<%== url_for('/')->to_abs() %>'+url; + return '<%== prefix() %>'+url; } function badToast(msg) {