Fix #174 — Show latest tag and commit of the instance

It’s showed in about page and config API endpoint
This commit is contained in:
Luc Didry 2020-05-20 08:54:26 +02:00
parent 89f1b60635
commit 17600fd679
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
7 changed files with 79 additions and 12 deletions

View File

@ -4,6 +4,7 @@ Revision history for Lufi
- Notifications when uploading and downloading files (#181) - Notifications when uploading and downloading files (#181)
- Use Weblate instead of Zanata for translations (https://weblate.framasoft.org/projects/lufi/development/) - Use Weblate instead of Zanata for translations (https://weblate.framasoft.org/projects/lufi/development/)
- Add config API endpoint (#183) - Add config API endpoint (#183)
- Show latest tag and commit of the instance in about page and config API endpoint (#174)
0.04.6 2019-11-07 0.04.6 2019-11-07
- Now can send large files (>2Gio) while using a DB other than SQLite (#165) - Now can send large files (>2Gio) while using a DB other than SQLite (#165)

View File

@ -32,7 +32,12 @@ sub change_lang {
} }
sub about { sub about {
shift->render(template => 'about'); my $c = shift;
$c->render(
template => 'about',
version => $c->git_version
);
} }
sub config_infos { sub config_infos {
@ -52,6 +57,7 @@ sub config_infos {
keep_ip_during => $c->config('keep_ip_during'), keep_ip_during => $c->config('keep_ip_during'),
stop_upload => (-f 'stop-upload' || -f 'stop-upload.manual') ? true : false, stop_upload => (-f 'stop-upload' || -f 'stop-upload.manual') ? true : false,
need_authentication => (defined($c->config('ldap')) || defined($c->config('htpasswd'))) ? true : false, need_authentication => (defined($c->config('ldap')) || defined($c->config('htpasswd'))) ? true : false,
version => $c->git_version
} }
); );
} }

View File

@ -69,6 +69,7 @@ sub register {
$app->helper(create_invitation_token => \&_create_invitation_token); $app->helper(create_invitation_token => \&_create_invitation_token);
$app->helper(is_guest => \&_is_guest); $app->helper(is_guest => \&_is_guest);
$app->helper(get_date_lang => \&_get_date_lang); $app->helper(get_date_lang => \&_get_date_lang);
$app->helper(git_version => \&_git_version);
} }
sub _pg { sub _pg {
@ -231,4 +232,18 @@ sub _get_date_lang {
return Date::Language->new('English'); return Date::Language->new('English');
} }
sub _git_version {
my $c = shift;
my $last_tag = `git describe --abbrev=0`;
my $last_commit = `git rev-parse HEAD`;
chomp $last_tag;
chomp $last_commit;
return {
tag => $last_tag,
commit => $last_commit
}
}
1; 1;

View File

@ -94,7 +94,7 @@ msgstr "As Lufi is a free software licensed under of the terms of the <a href=\"
msgid "Asking for file part XX1 of %1" msgid "Asking for file part XX1 of %1"
msgstr "Asking for file part XX1 of %1" msgstr "Asking for file part XX1 of %1"
#: themes/default/templates/about.html.ep:20 #: themes/default/templates/about.html.ep:23
msgid "Back to homepage" msgid "Back to homepage"
msgstr "Back to homepage" msgstr "Back to homepage"
@ -389,6 +389,16 @@ msgstr "Javascript is disabled. You won't be able to use Lufi."
msgid "Language" msgid "Language"
msgstr "Language" msgstr "Language"
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/commit/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:22
msgid "Latest commit of this instance: %1"
msgstr "Latest commit of this instance: %1"
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/releases/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:21
msgid "Latest tag of this instance: %1"
msgstr "Latest tag of this instance: %1"
#: themes/default/templates/login.html.ep:15 #: themes/default/templates/login.html.ep:15
msgid "Login" msgid "Login"
msgstr "Login" msgstr "Login"
@ -694,6 +704,10 @@ msgstr "Uploaded at"
msgid "Uploaded files" msgid "Uploaded files"
msgstr "Uploaded files" msgstr "Uploaded files"
#: themes/default/templates/about.html.ep:20
msgid "Version"
msgstr "Version"
#: themes/default/templates/partial/index.js.ep:31 #: themes/default/templates/partial/index.js.ep:31
msgid "Websocket communication error" msgid "Websocket communication error"
msgstr "Websocket communication error" msgstr "Websocket communication error"

View File

@ -441,6 +441,16 @@ msgstr "Javascript est désactivé. Lufi ne fonctionnera pas."
msgid "Language" msgid "Language"
msgstr "Langue" msgstr "Langue"
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/commit/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:22
msgid "Latest commit of this instance: %1"
msgstr "Dernier commit de cette instance : %1"
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/releases/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:21
msgid "Latest tag of this instance: %1"
msgstr "Dernière étiquette de cette instance : %1"
#: themes/default/templates/login.html.ep:15 #: themes/default/templates/login.html.ep:15
msgid "Login" msgid "Login"
msgstr "Identifiant" msgstr "Identifiant"
@ -833,6 +843,10 @@ msgstr "Envoyé le"
msgid "Uploaded files" msgid "Uploaded files"
msgstr "Fichiers envoyés" msgstr "Fichiers envoyés"
#: themes/default/templates/about.html.ep:20
msgid "Version"
msgstr "Version"
#: themes/default/templates/partial/index.js.ep:30 #: themes/default/templates/partial/index.js.ep:30
msgid "Websocket communication error" msgid "Websocket communication error"
msgstr "Erreur de communication WebSocket" msgstr "Erreur de communication WebSocket"

View File

@ -94,7 +94,7 @@ msgstr ""
msgid "Asking for file part XX1 of %1" msgid "Asking for file part XX1 of %1"
msgstr "" msgstr ""
#: themes/default/templates/about.html.ep:20 #: themes/default/templates/about.html.ep:23
msgid "Back to homepage" msgid "Back to homepage"
msgstr "" msgstr ""
@ -389,6 +389,16 @@ msgstr ""
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/commit/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:22
msgid "Latest commit of this instance: %1"
msgstr ""
#. (sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/releases/%s" class="classic">%s</a>', stash('version')
#: themes/default/templates/about.html.ep:21
msgid "Latest tag of this instance: %1"
msgstr ""
#: themes/default/templates/login.html.ep:15 #: themes/default/templates/login.html.ep:15
msgid "Login" msgid "Login"
msgstr "" msgstr ""
@ -694,6 +704,10 @@ msgstr ""
msgid "Uploaded files" msgid "Uploaded files"
msgstr "" msgstr ""
#: themes/default/templates/about.html.ep:20
msgid "Version"
msgstr ""
#: themes/default/templates/partial/index.js.ep:31 #: themes/default/templates/partial/index.js.ep:31
msgid "Websocket communication error" msgid "Websocket communication error"
msgstr "" msgstr ""

View File

@ -17,5 +17,8 @@
<p><%== l('As Lufi is a free software licensed under of the terms of the <a href="https://gnu.org/licenses/agpl.html" class="classic">AGPLv3</a>, you can install it on you own server. Have a look on the <a href="https://framagit.org/fiat-tux/hat-softwares/lufi/wikis/home" class="classic">Wiki</a> for the procedure.') %><br> <p><%== l('As Lufi is a free software licensed under of the terms of the <a href="https://gnu.org/licenses/agpl.html" class="classic">AGPLv3</a>, you can install it on you own server. Have a look on the <a href="https://framagit.org/fiat-tux/hat-softwares/lufi/wikis/home" class="classic">Wiki</a> for the procedure.') %><br>
<%== l('Get the source code on <a href="https://framagit.org/fiat-tux/hat-softwares/lufi" class="classic">the official repository</a> or on its <a href="https://github.com/ldidry/lufi" class="classic">Github mirror</a>') %> <%== l('Get the source code on <a href="https://framagit.org/fiat-tux/hat-softwares/lufi" class="classic">the official repository</a> or on its <a href="https://github.com/ldidry/lufi" class="classic">Github mirror</a>') %>
</p> </p>
<h3><%= l('Version') %></h3>
<p><%== l('Latest tag of this instance: %1', sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/releases/%s" class="classic">%s</a>', stash('version')->{tag}, stash('version')->{tag})) %></p>
<p><%== l('Latest commit of this instance: %1', sprintf('<a href="https://framagit.org/fiat-tux/hat-softwares/lufi/-/commit/%s" class="classic">%s</a>', stash('version')->{commit}, stash('version')->{commit})) %></p>
<p><%= link_to url_for('/') => ( class => "btn waves-effect waves-light cyan" ) => begin %><%= l('Back to homepage') %><% end%></p> <p><%= link_to url_for('/') => ( class => "btn waves-effect waves-light cyan" ) => begin %><%= l('Back to homepage') %><% end%></p>
</div> </div>