various fixes:

- changing default formatter option to plain text to make upgrading from
  0.19 Alpha smoother
- fixing translation message change in bootstrap templates
- adjusting how image uploads are displayed in bootstrap templates
This commit is contained in:
El RIDO 2015-09-19 14:22:29 +02:00
parent 844c4d15e9
commit a41d0ca4dd
5 changed files with 35 additions and 73 deletions

View File

@ -23,9 +23,9 @@ fileupload = false
; preselect the burn-after-reading feature, defaults to false ; preselect the burn-after-reading feature, defaults to false
burnafterreadingselected = false burnafterreadingselected = false
; which display mode to preselect by default, defaults to "syntaxhighlighting" ; which display mode to preselect by default, defaults to "plaintext"
; make sure the value exists in [formatter_options] ; make sure the value exists in [formatter_options]
defaultformatter = "syntaxhighlighting" defaultformatter = "plaintext"
; (optional) set a syntax highlighting theme, as found in css/prettify/ ; (optional) set a syntax highlighting theme, as found in css/prettify/
; syntaxhighlightingtheme = "sons-of-obsidian" ; syntaxhighlightingtheme = "sons-of-obsidian"

View File

@ -35,6 +35,7 @@ body.navbar-spacing {
#image img { #image img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
margin-bottom: 20px;
} }
#deletelink { #deletelink {

View File

@ -232,31 +232,25 @@ class zerobin
$ipKey = $header; $ipKey = $header;
} }
} }
if (!trafficlimiter::canPass($_SERVER[$ipKey])) if (!trafficlimiter::canPass($_SERVER[$ipKey])) return $this->_return_message(
{ 1,
$this->_return_message( i18n::_(
1, 'Please wait %d seconds between each post.',
i18n::_( $this->_conf['traffic']['limit']
'Please wait %d seconds between each post.', )
$this->_conf['traffic']['limit'] );
)
);
return;
}
// Make sure content is not too big. // Make sure content is not too big.
$sizelimit = (int) $this->_getMainConfig('sizelimit', 2097152); $sizelimit = (int) $this->_getMainConfig('sizelimit', 2097152);
if (strlen($data) + strlen($attachment) + strlen($attachmentname) > $sizelimit) if (
{ strlen($data) + strlen($attachment) + strlen($attachmentname) > $sizelimit
$this->_return_message( ) return $this->_return_message(
1, 1,
i18n::_( i18n::_(
'Paste is limited to %s of encrypted data.', 'Paste is limited to %s of encrypted data.',
filter::size_humanreadable($sizelimit) filter::size_humanreadable($sizelimit)
) )
); );
return;
}
// Make sure format is correct. // Make sure format is correct.
if (!sjcl::isValid($data)) return $this->_return_message(1, 'Invalid data.'); if (!sjcl::isValid($data)) return $this->_return_message(1, 'Invalid data.');
@ -268,7 +262,7 @@ class zerobin
!$this->_getMainConfig('fileupload', false) || !$this->_getMainConfig('fileupload', false) ||
!sjcl::isValid($attachment) || !sjcl::isValid($attachment) ||
!($has_attachmentname && sjcl::isValid($attachmentname)) !($has_attachmentname && sjcl::isValid($attachmentname))
) $this->_return_message(1, 'Invalid attachment.'); ) return $this->_return_message(1, 'Invalid attachment.');
} }
// Read additional meta-information. // Read additional meta-information.
@ -321,7 +315,7 @@ class zerobin
$formatter = $_POST['formatter']; $formatter = $_POST['formatter'];
if (!array_key_exists($formatter, $this->_conf['formatter_options'])) if (!array_key_exists($formatter, $this->_conf['formatter_options']))
{ {
$formatter = $this->_getMainConfig('defaultformatter', 'syntaxhighlighting'); $formatter = $this->_getMainConfig('defaultformatter', 'plaintext');
} }
$meta['formatter'] = $formatter; $meta['formatter'] = $formatter;
} }
@ -354,11 +348,7 @@ class zerobin
} }
} }
if ($error) if ($error) return $this->_return_message(1, 'Invalid data.');
{
$this->_return_message(1, 'Invalid data.');
return;
}
// Add post date to meta. // Add post date to meta.
$meta['postdate'] = time(); $meta['postdate'] = time();
@ -383,11 +373,7 @@ class zerobin
if ( if (
!filter::is_valid_paste_id($pasteid) || !filter::is_valid_paste_id($pasteid) ||
!filter::is_valid_paste_id($parentid) !filter::is_valid_paste_id($parentid)
) ) return $this->_return_message(1, 'Invalid data.');
{
$this->_return_message(1, 'Invalid data.');
return;
}
// Comments do not expire (it's the paste that expires) // Comments do not expire (it's the paste that expires)
unset($storage['expire_date']); unset($storage['expire_date']);
@ -396,43 +382,26 @@ class zerobin
// Make sure paste exists. // Make sure paste exists.
if ( if (
!$this->_model()->exists($pasteid) !$this->_model()->exists($pasteid)
) ) return $this->_return_message(1, 'Invalid data.');
{
$this->_return_message(1, 'Invalid data.');
return;
}
// Make sure the discussion is opened in this paste. // Make sure the discussion is opened in this paste.
$paste = $this->_model()->read($pasteid); $paste = $this->_model()->read($pasteid);
if ( if (
!$paste->meta->opendiscussion !$paste->meta->opendiscussion
) ) return $this->_return_message(1, 'Invalid data.');
{
$this->_return_message(1, 'Invalid data.');
return;
}
// Check for improbable collision. // Check for improbable collision.
if ( if (
$this->_model()->existsComment($pasteid, $parentid, $dataid) $this->_model()->existsComment($pasteid, $parentid, $dataid)
) ) return $this->_return_message(1, 'You are unlucky. Try again.');
{
$this->_return_message(1, 'You are unlucky. Try again.');
return;
}
// New comment // New comment
if ( if (
$this->_model()->createComment($pasteid, $parentid, $dataid, $storage) === false $this->_model()->createComment($pasteid, $parentid, $dataid, $storage) === false
) ) return $this->_return_message(1, 'Error saving comment. Sorry.');
{
$this->_return_message(1, 'Error saving comment. Sorry.');
return;
}
// 0 = no error // 0 = no error
$this->_return_message(0, $dataid); return $this->_return_message(0, $dataid);
return;
} }
// The user posts a standard paste. // The user posts a standard paste.
else else
@ -440,11 +409,7 @@ class zerobin
// Check for improbable collision. // Check for improbable collision.
if ( if (
$this->_model()->exists($dataid) $this->_model()->exists($dataid)
) ) return $this->_return_message(1, 'You are unlucky. Try again.');
{
$this->_return_message(1, 'You are unlucky. Try again.');
return;
}
// Add attachment and its name, if one was sent // Add attachment and its name, if one was sent
if ($has_attachment) $storage['attachment'] = $attachment; if ($has_attachment) $storage['attachment'] = $attachment;
@ -453,10 +418,7 @@ class zerobin
// New paste // New paste
if ( if (
$this->_model()->create($dataid, $storage) === false $this->_model()->create($dataid, $storage) === false
) { ) return $this->_return_message(1, 'Error saving paste. Sorry.');
$this->_return_message(1, 'Error saving paste. Sorry.');
return;
}
// Generate the "delete" token. // Generate the "delete" token.
// The token is the hmac of the pasteid signed with the server salt. // The token is the hmac of the pasteid signed with the server salt.
@ -464,8 +426,7 @@ class zerobin
$deletetoken = hash_hmac('sha1', $dataid, serversalt::get()); $deletetoken = hash_hmac('sha1', $dataid, serversalt::get());
// 0 = no error // 0 = no error
$this->_return_message(0, $dataid, array('deletetoken' => $deletetoken)); return $this->_return_message(0, $dataid, array('deletetoken' => $deletetoken));
return;
} }
} }
@ -609,7 +570,7 @@ class zerobin
} }
else else
{ {
$paste->meta->formatter = $this->_getMainConfig('defaultformatter', 'syntaxhighlighting'); $paste->meta->formatter = $this->_getMainConfig('defaultformatter', 'plaintext');
} }
} }
@ -680,7 +641,7 @@ class zerobin
$page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters)); $page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters));
$page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_getMainConfig('syntaxhighlightingtheme', '')); $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_getMainConfig('syntaxhighlightingtheme', ''));
$page->assign('FORMATTER', $formatters); $page->assign('FORMATTER', $formatters);
$page->assign('FORMATTERDEFAULT', $this->_getMainConfig('defaultformatter', 'syntaxhighlighting')); $page->assign('FORMATTERDEFAULT', $this->_getMainConfig('defaultformatter', 'plaintext'));
$page->assign('NOTICE', i18n::_($this->_getMainConfig('notice', ''))); $page->assign('NOTICE', i18n::_($this->_getMainConfig('notice', '')));
$page->assign('BURNAFTERREADINGSELECTED', $this->_getMainConfig('burnafterreadingselected', false)); $page->assign('BURNAFTERREADINGSELECTED', $this->_getMainConfig('burnafterreadingselected', false));
$page->assign('PASSWORD', $this->_getMainConfig('password', true)); $page->assign('PASSWORD', $this->_getMainConfig('password', true));

View File

@ -103,7 +103,7 @@
</div> </div>
</li>{/if}{if="$FILEUPLOAD"} </li>{/if}{if="$FILEUPLOAD"}
<li id="attach" class="hidden dropdown"> <li id="attach" class="hidden dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file:')"} <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file')"} <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li id="filewrap"> <li id="filewrap">
<div> <div>

View File

@ -86,7 +86,7 @@
</div> </div>
</li>{/if}{if="$FILEUPLOAD"} </li>{/if}{if="$FILEUPLOAD"}
<li id="attach" class="hidden dropdown"> <li id="attach" class="hidden dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file:')"} <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{function="t('Attach a file')"} <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li id="filewrap"> <li id="filewrap">
<div> <div>