Verified Commit 01a7e2ae authored by Luc Didry's avatar Luc Didry

Fix #49 - Handle very long URLs

This commit is dedicated to Schoumi, who is supporting me on Tipeee.
Many thanks 
parent f819ce92
Pipeline #78304 passed with stages
in 7 minutes and 27 seconds
......@@ -2,6 +2,9 @@ Revision history for Perl application Lstu
0.21-0 2018-??-??
0.20-2 2018-10-07
- Handle very long URLs
0.20-1 2018-09-20
- Fix safebrowsingcheck CLI help message
......
......@@ -36,11 +36,11 @@ sub add {
$c->respond_to(
json => { json => { success => Mojo::JSON->false, msg => $msg } },
any => sub {
my $c = shift;
$c->flash('msg' => $msg);
$c->flash('banned' => 1);
$c->redirect_to('index');
shift->render(
template => 'index',
msg => $msg,
banned => 1
);
}
);
} else {
......@@ -118,10 +118,10 @@ sub add {
$c->respond_to(
json => { json => { success => Mojo::JSON->false, msg => $msg } },
any => sub {
my $c = shift;
$c->flash('msg' => $msg);
$c->redirect_to('index');
shift->render(
template => 'index',
msg => $msg
);
}
);
} else {
......@@ -152,12 +152,12 @@ sub add {
$c->respond_to(
json => { json => { success => Mojo::JSON->true, url => $url, short => $prefix.$short, qrcode => $qrcode } },
any => sub {
my $c = shift;
$c->flash('url' => $url);
$c->flash('short' => $prefix.$short);
$c->flash('qrcode' => $qrcode);
$c->redirect_to('index');
shift->render(
template => 'index',
url => $url,
short => $prefix.$short,
qrcode => $qrcode
);
}
);
}
......
......@@ -12,13 +12,13 @@
<%= submit_button l('Go!'), class => 'btn btn-default btn-primary' %>
</form>
% if (defined(flash('short')) && defined(flash('url'))) {
% if (defined(stash('short')) && defined(stash('url'))) {
<h3 class="alert alert-success form-inline">
<img alt="QRCode" src="data:image/png;base64,<%= flash('qrcode') %>">
<img alt="QRCode" src="data:image/png;base64,<%= stash('qrcode') %>">
<div class="form-group">
<label><%= link_to flash('url') => begin %><%= flash('url') %><%= end %></a></label>
<br> =&gt; <input id="input-short" value="<%== flash('short') %>" class="form-control">
<span id="js" class="hidden"><a href="#" id="clipboard" class="btn btn-default" title="<%= l('Copy to clipboard') %>" data-short="<%== flash('short') %>"><span class="icon icon-clipboard"></span></a><span>
<label><%= link_to stash('url') => begin %><%= stash('url') %><%= end %></a></label>
<br> =&gt; <input id="input-short" value="<%== stash('short') %>" class="form-control">
<span id="js" class="hidden"><a href="#" id="clipboard" class="btn btn-default" title="<%= l('Copy to clipboard') %>" data-short="<%== stash('short') %>"><span class="icon icon-clipboard"></span></a><span>
</div>
</h3>
% }
......
......@@ -52,7 +52,7 @@
</p>
<%= content %>
</div>
% if (defined(flash('short')) && defined(flash('url'))) {
% if (defined(stash('short')) && defined(stash('url'))) {
%= javascript url_for('lstu.js')
% }
</body>
......
......@@ -10,12 +10,12 @@
</fieldset>
</form>
% if (defined(flash('short')) && defined(flash('url'))) {
% if (defined(stash('short')) && defined(stash('url'))) {
<fieldset class="result">
<img class="qrcode-result" alt="QRCode" src="data:image/png;base64,<%= flash('qrcode') %>">
<label><%= link_to flash('url') => begin %><h4><%= flash('url') %></h4><%= end %></label>
<input id="input-short" value="<%== flash('short') %>" class="form-control">
<span id="js" class="hidden"><a href="#" id="clipboard" class="button button-clear" title="<%= l('Copy to clipboard') %>" data-short="<%== flash('short') %>"><h5><span class="icon icon-clipboard"></span></h5></a><span>
<img class="qrcode-result" alt="QRCode" src="data:image/png;base64,<%= stash('qrcode') %>">
<label><%= link_to stash('url') => begin %><h4><%= stash('url') %></h4><%= end %></label>
<input id="input-short" value="<%== stash('short') %>" class="form-control">
<span id="js" class="hidden"><a href="#" id="clipboard" class="button button-clear" title="<%= l('Copy to clipboard') %>" data-short="<%== stash('short') %>"><h5><span class="icon icon-clipboard"></span></h5></a><span>
</fieldset>
% }
% if (defined(flash('msg'))) {
......
......@@ -52,7 +52,7 @@
%= stylesheet '/css/lstu.css'
%= stylesheet '/css/fontelico.css'
% }
% if (defined(flash('short')) && defined(flash('url'))) {
% if (defined(stash('short')) && defined(stash('url'))) {
%= javascript url_for('lstu.js')
% }
</body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment