displayurl_override

This commit is contained in:
Claude 2012-10-12 19:42:12 +02:00
parent 695d7fffcf
commit 53eb5a1c70
3 changed files with 21 additions and 5 deletions

View File

@ -38,6 +38,7 @@ Changelog
* Blocked words; maintain a comma separated list in your config, e.g. '.es.tl, mycraft.com, yourbadword' - pastes with this words will never get pasted * Blocked words; maintain a comma separated list in your config, e.g. '.es.tl, mycraft.com, yourbadword' - pastes with this words will never get pasted
* TODO: Spam trap for bots (thanks to the\_compiler, http://www.the-compiler.org/) * TODO: Spam trap for bots (thanks to the\_compiler, http://www.the-compiler.org/)
* Bugfix: Remove\_invisible\_characters removing legitimate paste content (https://github.com/claudehohl/Stikked/issues/28) * Bugfix: Remove\_invisible\_characters removing legitimate paste content (https://github.com/claudehohl/Stikked/issues/28)
* Possibility to manually set the paste's displayed URL (used with mod\_rewrite configurations)
* TODO: Print layout for pastes * TODO: Print layout for pastes
* TODO: Updated to CodeIgniter version 2.1.3 * TODO: Updated to CodeIgniter version 2.1.3

View File

@ -68,12 +68,11 @@ $config['per_page'] = 10;
* *
* private_only: No recent pastes will be displayed. * private_only: No recent pastes will be displayed.
* enable_captcha: Users must enter a captcha to post. * enable_captcha: Users must enter a captcha to post.
* blocked_words: Comma separated list, e.g. '.es.tl, mycraft.com, yourbadword'
* *
**/ **/
$config['private_only'] = false; $config['private_only'] = false;
$config['enable_captcha'] = false; $config['enable_captcha'] = false;
//blocked words; comma separated list, e.g. '.es.tl, mycraft.com, yourbadword'
$config['blocked_words'] = ''; $config['blocked_words'] = '';
//spamadmin: accessible via /spamadmin (only active when user + pass is set) //spamadmin: accessible via /spamadmin (only active when user + pass is set)
@ -117,6 +116,16 @@ $config['unknown_title'] = 'Untitled';
**/ **/
$config['require_auth'] = false; $config['require_auth'] = false;
/**
* Override the displayed URL
*
* Display this URL in a paste's detail view instead of the main URL - e.g. if you use mod_rewrite
* Variable $id: the paste_id
* Example: 'http://example.com/$id'
*
**/
$config['displayurl_override'] = '';
/** /**
* *
* *
@ -124,7 +133,6 @@ $config['require_auth'] = false;
* *
* *
**/ **/
$config['nouns'] = array('Hornbill', 'Elephant', 'Bison', 'Lion', 'Camel', 'Sheep', $config['nouns'] = array('Hornbill', 'Elephant', 'Bison', 'Lion', 'Camel', 'Sheep',
'Monkey', 'Prairie Dog', 'Plover', 'Tapir', 'Capybara', 'Cheetah', 'Flamingo', 'Peccary', 'Eider', 'Porcupine', 'Pelican', 'Dove', 'Crane', 'Tortoise', 'Agouti', 'Monkey', 'Prairie Dog', 'Plover', 'Tapir', 'Capybara', 'Cheetah', 'Flamingo', 'Peccary', 'Eider', 'Porcupine', 'Pelican', 'Dove', 'Crane', 'Tortoise', 'Agouti',
'Tamarin', 'Pheasant', 'Owl', 'Gibbon', 'Goose', 'Baboon', 'Hamerkop', 'Zebra', 'Tamarin', 'Pheasant', 'Owl', 'Gibbon', 'Goose', 'Baboon', 'Hamerkop', 'Zebra',

View File

@ -6,6 +6,7 @@
* - countPastes() * - countPastes()
* - countReplies() * - countReplies()
* - createPaste() * - createPaste()
* - _get_url()
* - checkPaste() * - checkPaste()
* - getPaste() * - getPaste()
* - calculate_hits() * - calculate_hits()
@ -116,7 +117,7 @@ class Pastes extends CI_Model
} }
else else
{ {
$url = site_url('view/' . $data['pid']); $url = $this->_get_url($data['pid']);
$url = urlencode($url); $url = urlencode($url);
$config_gwgd_url = $this->config->item('gwgd_url'); $config_gwgd_url = $this->config->item('gwgd_url');
$gwgd_url = ($config_gwgd_url ? $config_gwgd_url : 'http://gw.gd/'); $gwgd_url = ($config_gwgd_url ? $config_gwgd_url : 'http://gw.gd/');
@ -137,6 +138,12 @@ class Pastes extends CI_Model
$this->db->insert('pastes', $data); $this->db->insert('pastes', $data);
return 'view/' . $data['pid']; return 'view/' . $data['pid'];
} }
private
function _get_url($pid)
{
$override_url = $this->config->item('displayurl_override');
return ($override_url ? str_replace('$id', $pid, $override_url) : site_url('view/' . $pid));
}
function checkPaste($seg = 2) function checkPaste($seg = 2)
{ {
@ -185,7 +192,7 @@ class Pastes extends CI_Model
$data['lang'] = $this->languages->code_to_description($row['lang']); $data['lang'] = $this->languages->code_to_description($row['lang']);
$data['paste'] = $this->process->syntax(htmlspecialchars_decode($row['raw']) , $row['lang']); $data['paste'] = $this->process->syntax(htmlspecialchars_decode($row['raw']) , $row['lang']);
$data['created'] = $row['created']; $data['created'] = $row['created'];
$data['url'] = site_url('view/' . $row['pid']); $data['url'] = $this->_get_url($row['pid']);
$data['raw'] = $row['raw']; $data['raw'] = $row['raw'];
$data['hits'] = $row['hits']; $data['hits'] = $row['hits'];
$data['hits_updated'] = $row['hits_updated']; $data['hits_updated'] = $row['hits_updated'];