mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-05-18 15:26:14 +02:00
Webapp development, trying to send the image
Image sending is ok, but for some unknown reason, we can't have status message displayed once upload is complete.
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+16
-3
@@ -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;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 509 B |
+61
-2
@@ -122,7 +122,7 @@
|
||||
<div class="browser">
|
||||
<label>
|
||||
<span><%=l 'file-browser' %></span>
|
||||
<input type="file" name="files[]" multiple="multiple" title='<%=l 'file-browser' %>'>
|
||||
<input type="file" name="files[]" multiple="multiple" title='<%=l 'file-browser' %>' accept="image/*">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -191,7 +191,6 @@
|
||||
$('#'+id).prop('aria-valuenow', percent);
|
||||
$('#'+id).prop('style', 'width: '+percent+'%;');
|
||||
$('#'+id+'-text').html(percentStr);
|
||||
|
||||
},
|
||||
onUploadSuccess: function(id, data){
|
||||
$('#'+id+'-div').remove();
|
||||
@@ -241,6 +240,66 @@
|
||||
}
|
||||
}
|
||||
|
||||
function fileUpload(file) {
|
||||
var fd = new FormData();
|
||||
fd.append('file', file);
|
||||
|
||||
fd.append('format', 'json');
|
||||
fd.append('first-view', ($("#first-view").prop('checked')) ? 1 : 0);
|
||||
fd.append('crypt', ($("#crypt").prop('checked')) ? 1 : 0);
|
||||
fd.append('delete-day', ($("#delete-day").val()));
|
||||
|
||||
$(".messages").append('<div id="1-div">'+file.name+'<br><div class="progress"><div id="1"class="progress-bar progress-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"><span id="1-text" class="pull-left" style="padding-left: 10px;"> 0%</span></div></div></div>');
|
||||
// Ajax Submit
|
||||
$.ajax({
|
||||
url: '<%== url_for('add') %>',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: fd,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
forceSync: false,
|
||||
xhr: function(){
|
||||
var xhrobj = $.ajaxSettings.xhr();
|
||||
if(xhrobj.upload){
|
||||
xhrobj.upload.addEventListener('progress', function(event) {
|
||||
var percent = 0;
|
||||
var position = event.loaded || event.position;
|
||||
var total = event.total || e.totalSize;
|
||||
if(event.lengthComputable){
|
||||
percent = Math.ceil(position / total * 100);
|
||||
}
|
||||
|
||||
var percentStr = ' '+percent+'%';
|
||||
$('#1').prop('aria-valuenow', percent);
|
||||
$('#1').prop('style', 'width: '+percent+'%;');
|
||||
$('#1-text').html(percentStr);
|
||||
}, false);
|
||||
}
|
||||
|
||||
return xhrobj;
|
||||
},
|
||||
success: function (data, message, xhr){
|
||||
$('#1-div').remove();
|
||||
$(".messages").append(message(data.success, data.msg));
|
||||
},
|
||||
error: function (xhr, status, errMsg){
|
||||
$(".messages").append(message(false, ''));
|
||||
},
|
||||
});
|
||||
}
|
||||
window.onload = function() {
|
||||
navigator.mozSetMessageHandler('activity', function handler(activityRequest) {
|
||||
var activityName = activityRequest.source.name;
|
||||
if (activityName == 'share') {
|
||||
activity = activityRequest;
|
||||
blob = activity.source.data.blobs[0];
|
||||
fileUpload(blob);
|
||||
//blob = document.getElementById("lutim-file").value;
|
||||
}
|
||||
});
|
||||
};
|
||||
$('document').ready(function() {
|
||||
var firstview = ($("#first-view").prop('checked')) ? 1 : 0;
|
||||
var deleteday = ($("#delete-day").prop('checked')) ? 1 : 0;
|
||||
|
||||
@@ -18,29 +18,6 @@
|
||||
%= asset 'about.css'
|
||||
% } else {
|
||||
%= asset 'index.css'
|
||||
<script>
|
||||
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);
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
navigator.mozSetMessageHandler('activity', function handler(activityRequest) {
|
||||
var activityName = activityRequest.source.name;
|
||||
if (activityName == 'share')
|
||||
activity = activityRequest;
|
||||
blob = activity.source.data.blobs[0];
|
||||
blob = document.getElementById("lutim-file").value;
|
||||
});
|
||||
</script>
|
||||
% }
|
||||
</head>
|
||||
<body>
|
||||
@@ -63,7 +40,8 @@
|
||||
<%= link_to 'https://github.com/ldidry/lutim' => (title => l 'fork-me') => begin %><i class="lead icon icon-github-circled"></i><% end %>
|
||||
<%= link_to $twitter_url => (title => l 'share-twitter') => begin %><i class="lead icon icon-touiteur"></i><% end %>
|
||||
<%= link_to 'https://flattr.com/submit/auto?user_id=_SKy_&url='.$url.'&title=Lutim&category=software' => (title => 'Flattr this') => begin %><i class="lead icon icon-flattr"></i><% end %>
|
||||
<%= link_to 'bitcoin:1K3n4MXNRSMHk28oTfXEvDunWFthePvd8v?label=lutim' => (title => 'Give Bitcoins') => begin %><i class="lead icon icon-bitcoin"></i><% end %>
|
||||
<%= link_to 'bitcoin:1K3n4MXNRSMHk28oTfXEvDunWFthePvd8v?label=lutim' => (title => 'Give Bitcoins') => begin %><i class="lead icon icon-bitcoin"></i><% end %>
|
||||
<a class="btn btn-default btn-xs" href="#" id="install-app"><img src="img/rocket.png" alt="mozilla rocket logo"> <%=l 'install_as_webapp' %></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 %>
|
||||
</div>
|
||||
% if (defined(config('piwik_img'))) {
|
||||
|
||||
Reference in New Issue
Block a user