slight configuration changes, template modifications to make discussions

and password configurable, removed generated configuration test as it
grows quite big and a new one can be generated easily if needed
This commit is contained in:
El RIDO 2015-08-31 00:01:35 +02:00
parent 0198371049
commit d3c4600806
10 changed files with 184 additions and 17384 deletions

View file

@ -8,8 +8,11 @@
; @version 0.19
[main]
; enable or disable discussions, defaults to true
opendiscussion = true
; enable or disable the discussion feature, defaults to true
discussion = true
; preselect the discussion feature, defaults to false
opendiscussion = false
; enable or disable syntax highlighting, defaults to true
syntaxhighlighting = true
@ -20,6 +23,9 @@ syntaxhighlighting = true
; preselect the burn-after-reading feature, defaults to false
burnafterreadingselected = false
; enable or disable the password feature, defaults to true
password = true
; size limit per paste or comment in bytes, defaults to 2 Mibibytes
sizelimit = 2097152
@ -72,9 +78,9 @@ dir = PATH "data"
[model]
; name of data model class to load and directory for storage
; the default model "zerobin_data" stores everything in the filesystem
;class = zerobin_data
;[model_options]
;dir = PATH "data"
class = zerobin_data
[model_options]
dir = PATH "data"
;[model]
; example of DB configuration for MySQL
@ -88,10 +94,10 @@ dir = PATH "data"
;[model]
; example of DB configuration for SQLite
class = zerobin_db
[model_options]
dsn = "sqlite:" PATH "data/db.sq3"
usr = null
pwd = null
opt[12] = true ; PDO::ATTR_PERSISTENT
;class = zerobin_db
;[model_options]
;dsn = "sqlite:" PATH "data/db.sq3"
;usr = null
;pwd = null
;opt[12] = true ; PDO::ATTR_PERSISTENT

View file

@ -134,7 +134,7 @@ function zeroDecipher(key, data) {
try {
return decompress(sjcl.decrypt(key, data));
} catch (err) {
var password = prompt("Please enter the password for this paste.", "");
var password = prompt("Please enter the password for this paste:", "");
return decompress(sjcl.decrypt(key + sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(password)), data));
}
}
@ -423,7 +423,7 @@ function stateNewPaste() {
$('#discussion').addClass('hidden');
$('#prettymessage').addClass('hidden');
// Show password field
$('#password').show();
$('#password').removeClass('hidden');
}
/**

View file

@ -231,7 +231,7 @@ class zerobin
}
// Read open discussion flag.
if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion']))
if ($this->_conf['main']['discussion'] && !empty($_POST['opendiscussion']))
{
$opendiscussion = $_POST['opendiscussion'];
if ($opendiscussion !== '0')
@ -489,11 +489,13 @@ class zerobin
$page->assign('ERROR', $this->_error);
$page->assign('STATUS', $this->_status);
$page->assign('VERSION', self::VERSION);
$page->assign('DISCUSSION', $this->_getMainConfig('discussion', true));
$page->assign('OPENDISCUSSION', $this->_getMainConfig('opendiscussion', true));
$page->assign('SYNTAXHIGHLIGHTING', $this->_getMainConfig('syntaxhighlighting', true));
$page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_getMainConfig('syntaxhighlightingtheme', ''));
$page->assign('NOTICE', $this->_getMainConfig('notice', ''));
$page->assign('BURNAFTERREADINGSELECTED', $this->_getMainConfig('burnafterreadingselected', false));
$page->assign('PASSWORD', $this->_getMainConfig('password', true));
$page->assign('BASE64JSVERSION', $this->_getMainConfig('base64version', '2.1.9'));
$page->assign('EXPIRE', $expire);
$page->assign('EXPIREDEFAULT', $this->_conf['expire']['default']);

View file

@ -63,7 +63,7 @@
<a id="expiration" href="#" class="hidden dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Expires <span id="pasteExpirationDisplay"></span> <span class="caret"></span></a>
<ul class="dropdown-menu">
{loop="EXPIRE"}
<li><a href="#" onclick="$('#pasteExpiration').val('{$key}');$('#pasteExpirationDisplay').val('{$value}');return false;">{$value}</a></li>{/loop}
<li><a href="#" onclick="$('#pasteExpiration').val('{$key}');$('#pasteExpirationDisplay').text('{$value}');return false;">{$value}</a></li>{/loop}
</ul>
</li>
<li>
@ -73,20 +73,20 @@
Burn after reading
</label>
</div>
</li>
</li>{if="$DISCUSSION"}
<li>
<div id="opendisc" class="navbar-text checkbox hidden">
<label>
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="!$OPENDISCUSSION"} disabled="disabled"{/if} />
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="$OPENDISCUSSION"} checked="checked"{/if} />
Open discussion
</label>
</div>
</li>
</li>{/if}{if="$PASSWORD"}
<li>
<div id="password" class="navbar-text" style="display:none;" >
<input type="password" id="passwordinput" placeholder="Password (optional)" size="19"/>
<div id="password" class="navbar-form hidden">
<input type="password" id="passwordinput" placeholder="Password (optional)" class="form-control" size="19"/>
</div>
</li>
</li>{/if}
<li>
<p id="remainingtime" class="hidden navbar-text"></p>
</li>

View file

@ -57,12 +57,14 @@
<div id="burnafterreadingoption" class="button hidden">
<input type="checkbox" id="burnafterreading" name="burnafterreading" {if="$BURNAFTERREADINGSELECTED"} checked="checked"{/if} />
<label for="burnafterreading">Burn after reading</label>
</div>
</div>{if="$DISCUSSION"}
<div id="opendisc" class="button hidden">
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="!$OPENDISCUSSION"} disabled="disabled"{/if} />
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="$OPENDISCUSSION"} checked="checked"{/if} />
<label for="opendiscussion" {if="!$OPENDISCUSSION"} style="color: #BBBBBB;"{/if}>Open discussion</label>
</div>
<input id="password" placeholder="Optional password (recommended)" size="32" style="display:none;" />
</div>{/if}{if="$PASSWORD"}
<div id="password" class="hidden">
<input id="passwordinput" placeholder="Optional password (recommended)" size="32" />
</div>{/if}
</div>
<div id="pasteresult" class="hidden">
<div id="deletelink"></div>

1
tst/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/configuration.php

View file

@ -31,10 +31,12 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
$page->assign('ERROR', self::$error);
$page->assign('STATUS', self::$status);
$page->assign('VERSION', self::$version);
$page->assign('BURNAFTERREADINGSELECTED', false);
$page->assign('OPENDISCUSSION', false);
$page->assign('DISCUSSION', true);
$page->assign('OPENDISCUSSION', true);
$page->assign('SYNTAXHIGHLIGHTING', true);
$page->assign('SYNTAXHIGHLIGHTINGTHEME', 'sons-of-obsidian');
$page->assign('BURNAFTERREADINGSELECTED', false);
$page->assign('PASSWORD', true);
$page->assign('BASE64JSVERSION', '2.1.9');
$page->assign('NOTICE', 'example');
$page->assign('EXPIRE', self::$expire);
@ -72,15 +74,29 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
$this->_content,
'outputs error correctly'
);
$this->assertTag(
array(
'id' => 'password',
),
$this->_content,
'password available if configured'
);
$this->assertTag(
array(
'id' => 'opendiscussion',
'attributes' => array(
'disabled' => 'disabled'
'checked' => 'checked'
),
),
$this->_content,
'disables discussions if configured'
'checked discussion if configured'
);
$this->assertTag(
array(
'id' => 'opendisc',
),
$this->_content,
'discussions available if configured'
);
// testing version number in JS address, since other instances may not be present in different templates
$this->assertTag(

View file

@ -16,19 +16,16 @@ $vrd = array('view', 'read', 'delete');
$vcud = array('view', 'create', 'read', 'delete');
new configurationTestGenerator(array(
'main/opendiscussion' => array(
'main/discussion' => array(
array(
'setting' => true,
'tests' => array(
array(
'conditions' => array('steps' => $vrd),
'type' => 'NotTag',
'type' => 'Tag',
'args' => array(
array(
'id' => 'opendiscussion',
'attributes' => array(
'disabled' => 'disabled',
),
'id' => 'opendisc',
),
'$content',
'outputs enabled discussion correctly'
@ -57,16 +54,54 @@ new configurationTestGenerator(array(
'setting' => false,
'tests' => array(
array(
'type' => 'NotTag',
'args' => array(
array(
'id' => 'opendisc',
),
'$content',
'outputs disabled discussion correctly'
),
),
),
'affects' => $vrd
),
),
'main/opendiscussion' => array(
array(
'setting' => true,
'tests' => array(
array(
'conditions' => array('main/discussion' => true),
'type' => 'Tag',
'args' => array(
array(
'id' => 'opendiscussion',
'attributes' => array(
'disabled' => 'disabled',
'checked' => 'checked',
),
),
'$content',
'outputs disabled discussion correctly'
'outputs checked discussion correctly'
),
),
),
'affects' => $vrd
), array(
'setting' => false,
'tests' => array(
array(
'conditions' => array('main/discussion' => true),
'type' => 'NotTag',
'args' => array(
array(
'id' => 'opendiscussion',
'attributes' => array(
'checked' => 'checked',
),
),
'$content',
'outputs unchecked discussion correctly'
),
),
),
@ -240,6 +275,40 @@ new configurationTestGenerator(array(
'affects' => array('view'),
),
),
'main/password' => array(
array(
'setting' => true,
'tests' => array(
array(
'type' => 'Tag',
'args' => array(
array(
'id' => 'password',
),
'$content',
'outputs password input correctly'
),
),
),
'affects' => $vrd
), array(
'setting' => false,
'tests' => array(
array(
'conditions' => array('main/discussion' => true),
'type' => 'NotTag',
'args' => array(
array(
'id' => 'password',
),
'$content',
'removes password input correctly'
),
),
),
'affects' => $vrd
),
),
'main/template' => array(
array(
'setting' => 'page',
@ -421,7 +490,7 @@ class configurationTestGenerator
* creating factorial configurations
* @var int
*/
const MAX_ITERATIONS = 1000;
const MAX_ITERATIONS = 2000;
/**
* options to test

File diff suppressed because it is too large Load diff

49
tst/test.ini Normal file
View file

@ -0,0 +1,49 @@
[main]
discussion = true
opendiscussion = true
syntaxhighlighting = true
burnafterreadingselected = true
password = true
sizelimit = 10
template = "page"
base64version = "2.1.9"
syntaxhighlightingtheme = "sons-of-obsidian"
[expire]
default = "1week"
[expire_options]
5min = "300"
10min = "600"
1hour = "3600"
1day = "86400"
1week = "604800"
1month = "2592000"
1year = "31536000"
never = "0"
[expire_labels]
5min = "5 minutes"
10min = "10 minutes"
1hour = "1 hour"
1day = "1 day"
1week = "1 week"
1month = "1 month"
1year = "1 year"
never = "Never"
[traffic]
limit = 0
dir = "../data"
[model]
class = "zerobin_db"
[model_options]
dsn = "sqlite:../data/db.sq3"
usr = ""
pwd = ""
opt = array (
12 => '1',
)