fixing page template, removing error messages when markdown or source are disabled in configuration, re-removing unnecessary spans
This commit is contained in:
parent
97171ec1f8
commit
81b00dd422
@ -102,15 +102,10 @@ body.loading {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.pl-1::before {
|
||||
content: " ";
|
||||
}
|
||||
|
||||
.comment {
|
||||
border-left: 1px solid #ccc;
|
||||
padding: 5px 0 5px 10px;
|
||||
white-space: pre-wrap;
|
||||
|
||||
transition: background-color 0.75s ease-out;
|
||||
}
|
||||
|
||||
@ -119,8 +114,6 @@ body.loading {
|
||||
transition: background-color 0.2s ease-in;
|
||||
}
|
||||
|
||||
|
||||
|
||||
footer h4 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
@ -995,7 +995,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
|
||||
var $errorMessage,
|
||||
$loadingIndicator,
|
||||
$statusMessage;
|
||||
$statusMessage,
|
||||
$remainingTime;
|
||||
|
||||
var currentIcon = [
|
||||
'glyphicon-time', // loading icon
|
||||
@ -1036,7 +1037,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
args = [args];
|
||||
}
|
||||
|
||||
// pass to custom handler if dfined
|
||||
// pass to custom handler if defined
|
||||
if (typeof customHandler === 'function') {
|
||||
var handlerResult = customHandler(alertType[id], $element, args, icon);
|
||||
if (handlerResult === true) {
|
||||
@ -1069,11 +1070,13 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
|
||||
// show text
|
||||
if (args !== null) {
|
||||
// add jQuery object to it as first parameter
|
||||
args.unshift($element.find(':last'));
|
||||
|
||||
// pass it to I18n
|
||||
I18n._.apply(this, args);
|
||||
// get last text node of element
|
||||
var content = $element.contents();
|
||||
if (content.length > 1) {
|
||||
content[content.length - 1].nodeValue = ' ' + I18n._(args);
|
||||
} else {
|
||||
$element.text(I18n._(args));
|
||||
}
|
||||
}
|
||||
|
||||
// show notification
|
||||
@ -1130,6 +1133,21 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
handleNotification(3, $errorMessage, message, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* display remaining message
|
||||
*
|
||||
* This automatically passes the text to I18n for translation.
|
||||
*
|
||||
* @name Alert.showRemaining
|
||||
* @function
|
||||
* @param {string|array} message string, use an array for %s/%d options
|
||||
*/
|
||||
me.showRemaining = function(message)
|
||||
{
|
||||
console.error('remaining message shown: ', message);
|
||||
handleNotification(1, $remainingTime, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* shows a loading message, optionally with a percentage
|
||||
*
|
||||
@ -1230,18 +1248,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
$errorMessage = $('#errormessage');
|
||||
$loadingIndicator = $('#loadingindicator');
|
||||
$statusMessage = $('#status');
|
||||
|
||||
// display status returned by php code, if any (e.g. paste was properly deleted)
|
||||
var serverStatus = $statusMessage.text();
|
||||
if (Helper.isValidText(serverStatus)) {
|
||||
me.showStatus();
|
||||
}
|
||||
|
||||
// display error message from php code
|
||||
var serverError = $errorMessage.text();
|
||||
if (Helper.isValidText(serverError)) {
|
||||
Alert.showError();
|
||||
}
|
||||
$remainingTime = $('#remainingtime');
|
||||
}
|
||||
|
||||
return me;
|
||||
@ -1339,7 +1346,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
// actually remove paste, before we claim it is deleted
|
||||
Controller.removePaste(Model.getPasteId(), 'burnafterreading');
|
||||
|
||||
I18n._($remainingTime.find(':last'), "FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.");
|
||||
Alert.showRemaining("FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.");
|
||||
$remainingTime.addClass('foryoureyesonly');
|
||||
|
||||
// discourage cloning (it cannot really be prevented)
|
||||
@ -1353,7 +1360,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
'This document will expire in %d ' + expiration[1] + 's.'
|
||||
];
|
||||
|
||||
I18n._($remainingTime.find(':last'), expirationLabel, expiration[0]);
|
||||
Alert.showRemaining(expirationLabel, expiration[0]);
|
||||
$remainingTime.removeClass('foryoureyesonly')
|
||||
} else {
|
||||
// never expires
|
||||
@ -1620,7 +1627,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||
$message.addClass('hidden');
|
||||
|
||||
// show preview
|
||||
$('#errormessage').find(':last')
|
||||
PasteViewer.setText($message.val());
|
||||
PasteViewer.run();
|
||||
|
||||
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rvc7nkZjk/ntvq0byTiVQX6lP+vXkg0TwZ+LLd7EpeV+7Rr2hm/bUwOrc77t1JkIicywjvfu6tKYBWVkjuCHNw==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Np6M1TYAhyN/c5SaNYsTnQW+yLyMW3zr/TuiJipi77GxWdayOxcc/3CqCodtm5YPxxdyIwhjjJTclMOdwjdBKQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@ -122,7 +122,7 @@ endif;
|
||||
<ul class="nav navbar-nav">
|
||||
<li id="loadingindicator" class="navbar-text hidden">
|
||||
<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
|
||||
<span class="pl-1"><?php echo I18n::_('Loading…'), PHP_EOL; ?></span>
|
||||
<?php echo I18n::_('Loading…'), PHP_EOL; ?>
|
||||
</li>
|
||||
<li>
|
||||
<?php
|
||||
@ -379,31 +379,46 @@ endif;
|
||||
if (strlen($NOTICE)):
|
||||
?>
|
||||
<div role="alert" class="alert alert-info">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><span class="pl-1"><?php echo htmlspecialchars($NOTICE), PHP_EOL; ?></span>
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
<?php echo htmlspecialchars($NOTICE), PHP_EOL; ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<div id="remainingtime" role="alert" class="hidden alert alert-info">
|
||||
<span class="glyphicon glyphicon-fire" aria-hidden="true"></span><span class="pl-1"></span>
|
||||
<span class="glyphicon glyphicon-fire" aria-hidden="true"></span>
|
||||
</div>
|
||||
<?php
|
||||
if ($FILEUPLOAD):
|
||||
?>
|
||||
<div id="attachment" role="alert" class="hidden alert alert-info">
|
||||
<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span><a class="alert-link pl-1"><?php echo I18n::_('Download attachment'); ?></a>
|
||||
<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
|
||||
<a class="alert-link"><?php echo I18n::_('Download attachment'), PHP_EOL; ?></a>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<div id="status" role="alert" class="statusmessage alert alert-info<?php echo empty($STATUS) ? ' hidden' : '' ?>">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
<span class="pl-1"><?php echo htmlspecialchars($STATUS); ?></span>
|
||||
<?php echo htmlspecialchars($STATUS), PHP_EOL; ?>
|
||||
</div>
|
||||
<div id="errormessage" role="alert" class="statusmessage<?php echo empty($ERROR) ? ' hidden' : '' ?> alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><span class="pl-1"><?php echo htmlspecialchars($ERROR); ?></span></div>
|
||||
<noscript><div id="noscript" role="alert" class="nonworking alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php echo I18n::_('JavaScript is required for %s to work.<br />Sorry for the inconvenience.', I18n::_($NAME)); ?></div></noscript>
|
||||
<div id="oldienotice" role="alert" class="hidden nonworking alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><?php echo I18n::_('%s requires a modern browser to work.', I18n::_($NAME)); ?></div>
|
||||
<div id="ienotice" role="alert" class="hidden alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span><?php echo I18n::_('Still using Internet Explorer? Do yourself a favor, switch to a modern browser:'), PHP_EOL; ?>
|
||||
<div id="errormessage" role="alert" class="statusmessage<?php echo empty($ERROR) ? ' hidden' : '' ?> alert alert-danger">
|
||||
<span class="glyphicon glyphicon-alert" aria-hidden="true"></span>
|
||||
<?php echo htmlspecialchars($ERROR), PHP_EOL; ?>
|
||||
</div>
|
||||
<noscript>
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>">
|
||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||
<?php echo I18n::_('JavaScript is required for %s to work.<br />Sorry for the inconvenience.', I18n::_($NAME)), PHP_EOL; ?>
|
||||
</div>
|
||||
</noscript>
|
||||
<div id="oldienotice" role="alert" class="hidden nonworking alert alert-danger">
|
||||
<span class="glyphicon glyphicon-alert" aria-hidden="true"></span>
|
||||
<?php echo I18n::_('%s requires a modern browser to work.', I18n::_($NAME)), PHP_EOL; ?>
|
||||
</div>
|
||||
<div id="ienotice" role="alert" class="hidden alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>">
|
||||
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
|
||||
<?php echo I18n::_('Still using Internet Explorer? Do yourself a favor, switch to a modern browser:'), PHP_EOL; ?>
|
||||
<a href="https://www.mozilla.org/firefox/">Firefox</a>,
|
||||
<a href="https://www.opera.com/">Opera</a>,
|
||||
<a href="https://www.google.com/chrome">Chrome</a>…
|
||||
@ -446,8 +461,9 @@ endif;
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span class="pl-1"><?php echo I18n::_('Loading…'); ?></span><br />
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide">
|
||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||
<?php echo I18n::_('Loading…'); ?><br />
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
@ -469,7 +485,7 @@ if ($DISCUSSION):
|
||||
<div id="templates">
|
||||
<!-- @TODO: when I intend/structure this corrrectly Firefox adds whitespaces everywhere which completly destroy the layout. (same possible when you remove the template data below and show this area in the browser) -->
|
||||
<article id="commenttemplate" class="comment"><div class="commentmeta"><span class="nickname">name</span><span class="commentdate">0000-00-00</span></div><div class="commentdata">c</div><button class="btn btn-default btn-sm"><?php echo I18n::_('Reply'); ?></button></article>
|
||||
<div id="commenttailtemplate" class="comment"><button class="btn btn-default btn-sm"><?php echo I18n::_('Add comment'); ?></button></div>
|
||||
<p id="commenttailtemplate" class="comment"><button class="btn btn-default btn-sm"><?php echo I18n::_('Add comment'); ?></button></p>
|
||||
<div id="replytemplate" class="reply hidden"><input type="text" id="nickname" class="form-control" title="<?php echo I18n::_('Optional nickname…'); ?>" placeholder="<?php echo I18n::_('Optional nickname…'); ?>" /><textarea id="replymessage" class="replymessage form-control" cols="80" rows="7"></textarea><br /><div id="replystatus" role="alert" class="statusmessage hidden alert"><span class="glyphicon" aria-hidden="true"></span><span></span></div><button id="replybutton" class="btn btn-default btn-sm"><?php echo I18n::_('Post comment'); ?></button></div>
|
||||
</div>
|
||||
<?php
|
||||
|
21
tpl/page.php
21
tpl/page.php
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rvc7nkZjk/ntvq0byTiVQX6lP+vXkg0TwZ+LLd7EpeV+7Rr2hm/bUwOrc77t1JkIicywjvfu6tKYBWVkjuCHNw==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Np6M1TYAhyN/c5SaNYsTnQW+yLyMW3zr/TuiJipi77GxWdayOxcc/3CqCodtm5YPxxdyIwhjjJTclMOdwjdBKQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@ -84,6 +84,7 @@ endif;
|
||||
</header>
|
||||
<section>
|
||||
<article>
|
||||
<div id="loadingindicator" class="hidden"><?php echo I18n::_('Loading…'); ?></div>
|
||||
<div id="status"><?php echo htmlspecialchars($STATUS); ?></div>
|
||||
<div id="errormessage" class="hidden"><?php echo htmlspecialchars($ERROR); ?></div>
|
||||
<div id="toolbar">
|
||||
@ -215,17 +216,31 @@ endif;
|
||||
<div id="prettymessage" class="hidden">
|
||||
<pre id="prettyprint" class="prettyprint linenums:1"></pre>
|
||||
</div>
|
||||
<div id="cleartext" class="hidden"></div>
|
||||
<div id="plaintext" class="hidden"></div>
|
||||
<textarea id="message" name="message" cols="80" rows="25" class="hidden"></textarea>
|
||||
</article>
|
||||
</section>
|
||||
<section>
|
||||
<div id="discussion" class="hidden">
|
||||
<h4 class="title"><?php echo I18n::_('Discussion'); ?></h4>
|
||||
<div id="comments"></div>
|
||||
<div id="commentcontainer"></div>
|
||||
</div>
|
||||
</section>
|
||||
<div id="serverdata" class="hidden" aria-hidden="true">
|
||||
<div id="cipherdata" class="hidden"><?php echo htmlspecialchars($CIPHERDATA, ENT_NOQUOTES); ?></div>
|
||||
<?php
|
||||
if ($DISCUSSION):
|
||||
?>
|
||||
<div id="templates">
|
||||
<!-- @TODO: when I intend/structure this corrrectly Firefox adds whitespaces everywhere which completly destroy the layout. (same possible when you remove the template data below and show this area in the browser) -->
|
||||
<article id="commenttemplate" class="comment"><div class="commentmeta"><span class="nickname">name</span><span class="commentdate">0000-00-00</span></div><div class="commentdata">c</div><button class="btn btn-default btn-sm"><?php echo I18n::_('Reply'); ?></button></article>
|
||||
<div id="commenttailtemplate" class="comment"><button class="btn btn-default btn-sm"><?php echo I18n::_('Add comment'); ?></button></div>
|
||||
<div id="replytemplate" class="reply hidden"><input type="text" id="nickname" class="form-control" title="<?php echo I18n::_('Optional nickname…'); ?>" placeholder="<?php echo I18n::_('Optional nickname…'); ?>" /><textarea id="replymessage" class="replymessage form-control" cols="80" rows="7"></textarea><br /><div id="replystatus" role="alert" class="statusmessage hidden alert"><span class="glyphicon" aria-hidden="true"></span><span></span></div><button id="replybutton" class="btn btn-default btn-sm"><?php echo I18n::_('Post comment'); ?></button></div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
|
@ -760,7 +760,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.#s',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -778,7 +778,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -798,7 +798,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -939,7 +939,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.</#s',
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
);
|
||||
@ -960,7 +960,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -980,7 +980,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -1000,7 +1000,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Wrong deletion token\. Paste was not deleted\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Wrong deletion token\. Paste was not deleted\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -1067,7 +1067,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.</#',
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -1091,7 +1091,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.</#s',
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
);
|
||||
|
@ -104,7 +104,7 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
$template . ': outputs data correctly'
|
||||
);
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '</#',
|
||||
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '#s',
|
||||
$content,
|
||||
$template . ': outputs error correctly'
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user