diff --git a/lib/Lutim.pm b/lib/Lutim.pm index 4d155c5..1b88463 100644 --- a/lib/Lutim.pm +++ b/lib/Lutim.pm @@ -321,6 +321,10 @@ sub startup { to('Controller#stats')-> name('stats'); + $r->get('/manifest.webapp')-> + to('Controller#webapp')-> + name('manifest.webapp'); + $r->post('/')-> to('Controller#add')-> name('add'); diff --git a/lib/Lutim/Controller.pm b/lib/Lutim/Controller.pm index d2b9b6d..494cc05 100644 --- a/lib/Lutim/Controller.pm +++ b/lib/Lutim/Controller.pm @@ -46,6 +46,19 @@ sub stats { ); } +sub webapp { + my $c = shift; + + my $headers = Mojo::Headers->new(); + $headers->add('Content-Type' => 'application/x-web-app-manifest+json'); + $c->res->content->headers($headers); + + $c->render( + template => 'manifest', + format => 'webapp' + ); +} + sub delete { my $c = shift; my $short = $c->param('short'); diff --git a/lib/Lutim/I18N/en.pm b/lib/Lutim/I18N/en.pm index 99f0e3e..89a7b96 100644 --- a/lib/Lutim/I18N/en.pm +++ b/lib/Lutim/I18N/en.pm @@ -82,6 +82,7 @@ our %Lexicon = ( 'image_deleted' => 'The image [_1] has been successfully deleted', 'invalid_token' => 'The delete token is invalid.', 'already_deleted' => 'The image [_1] has already been deleted.', + 'install_as_webapp' => 'Install webapp', ); 1; diff --git a/lib/Lutim/I18N/fr.pm b/lib/Lutim/I18N/fr.pm index 9b57cb9..37d7065 100644 --- a/lib/Lutim/I18N/fr.pm +++ b/lib/Lutim/I18N/fr.pm @@ -82,6 +82,7 @@ our %Lexicon = ( 'image_deleted' => 'L\'image [_1] a été supprimée avec succès.', 'invalid_token' => 'Le jeton de suppression est invalide.', 'already_deleted' => 'L\'image [_1] a déjà été supprimée.', + 'install_as_webapp' => 'Installer la webapp', ); 1; diff --git a/public/css/lutim.css b/public/css/lutim.css index 9929ca7..dd0bd25 100644 --- a/public/css/lutim.css +++ b/public/css/lutim.css @@ -1,6 +1,15 @@ -body { - padding-top: 40px; - padding-bottom: 40px; +@media (max-width: 767px) { + body { + padding-top: 5px; + padding-bottom: 5px; + } +} + +@media (min-width: 768px) { + body { + padding-top: 40px; + padding-bottom: 40px; + } } .container { @@ -32,3 +41,7 @@ label.always-encrypt { color: #000000; text-decoration: none; } + +#install-app img { + height: 22px; +} diff --git a/public/img/lutim128.png b/public/img/lutim128.png index c7f1d56..392d446 100644 Binary files a/public/img/lutim128.png and b/public/img/lutim128.png differ diff --git a/public/img/rocket.png b/public/img/rocket.png new file mode 100644 index 0000000..f855a02 Binary files /dev/null and b/public/img/rocket.png differ diff --git a/templates/index.html.ep b/templates/index.html.ep index eb93da4..7783053 100644 --- a/templates/index.html.ep +++ b/templates/index.html.ep @@ -122,7 +122,7 @@
<%=l 'install_as_webapp' %>
@@ -82,6 +60,21 @@
% } elsif (!(current_route 'about')) {
%= asset 'index.js'
% }
+ %= javascript begin
+ $('#install-app').click(function() {
+ var manifestUrl = '<%== url_for('manifest.webapp')->to_abs() %>';
+ var request = window.navigator.mozApps.install(manifestUrl);
+ request.onsuccess = function () {
+ // Save the App object that is returned
+ var appRecord = this.result;
+ //alert('Installation successful!');
+ };
+ request.onerror = function () {
+ // Display the error information from the DOMError object
+ alert('Install failed, error: ' + this.error.name);
+ };
+ });
+ % end
<%= content %>
% if (defined(config('piwik_img'))) {