From a73791f16d10ea0e2c477f29d9049d75516aa774 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 01:17:46 -0400 Subject: Added OpenID Authentication --- data/config.default.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'data/config.default.php') diff --git a/data/config.default.php b/data/config.default.php index 88c9ae5..7ecbda3 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -12,6 +12,11 @@ $GLOBALS['phorkie']['cfg'] = array( 'geshi' => 'MediaWiki/geshi/geshi/geshi.php', 'index' => 'new'//"new" or "list" ); +$GLOBALS['phorkie']['auth'] = array( + 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication + 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits +); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, '\\phorkie\\Tool_PHPlint' => true, -- cgit v1.2.3 From 5935a357efd7be14481b21560347f70116891e16 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sun, 16 Sep 2012 13:52:17 -0400 Subject: ADD: Commit as logged in user --- data/config.default.php | 1 + src/phorkie/Repository/Post.php | 14 ++++++++++---- www/edit.php | 2 +- www/new.php | 2 +- www/www-header.php | 6 ++++++ 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'data/config.default.php') diff --git a/data/config.default.php b/data/config.default.php index 7ecbda3..da16241 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -15,6 +15,7 @@ $GLOBALS['phorkie']['cfg'] = array( $GLOBALS['phorkie']['auth'] = array( 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + 'anonymousName' => 'Anonymous', // Email for non-authenticated commits 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index de987e0..ed44cf1 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -15,7 +15,7 @@ class Repository_Post * * @return boolean True if the post was successful */ - public function process($postData) + public function process($postData, $sessionData) { if (!isset($postData['files'])) { return false; @@ -117,11 +117,17 @@ class Repository_Post } } + $commitmsg = "phorkie commit"; + if (isset($sessionData['identity'])) { + $commitmsg .= " from ".$sessionData['identity']; + } else { + $commitmsg .= " by ".$sessionData['ipaddr']; + } + if ($bCommit) { $vc->getCommand('commit') - ->setOption('message', '') - ->setOption('allow-empty-message') - ->setOption('author', 'Anonymous ') + ->setOption('message', $commitmsg) + ->setOption('author', $sessionData['name'].' <'.$sessionData['email'].'>') ->execute(); $bChanged = true; } diff --git a/www/edit.php b/www/edit.php index 226b774..db4428b 100644 --- a/www/edit.php +++ b/www/edit.php @@ -12,7 +12,7 @@ $repo = new Repository(); $repo->loadFromRequest(); $repopo = new Repository_Post($repo); -if ($repopo->process($_POST)) { +if ($repopo->process($_POST, $_SESSION)) { redirect($repo->getLink('display')); } diff --git a/www/new.php b/www/new.php index fc6d5f3..8d1a231 100644 --- a/www/new.php +++ b/www/new.php @@ -16,7 +16,7 @@ if ($GLOBALS['phorkie']['auth']['secure'] > 0) { } $repopo = new Repository_Post(); -if ($repopo->process($_POST)) { +if ($repopo->process($_POST, $_SESSION)) { redirect($repopo->repo->getLink('display')); } diff --git a/www/www-header.php b/www/www-header.php index 74863e1..5785a3e 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -47,6 +47,12 @@ if (file_exists(__DIR__ . '/../data/config.php')) { if ($GLOBALS['phorkie']['cfg']['setupcheck']) { SetupCheck::run(); } + +// Set/Get git commit session variables +$_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR']; +if (!isset($_SESSION['name'])) { $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName']; } +if (!isset($_SESSION['email'])) { $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail']; } + \Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']); -- cgit v1.2.3 From 3367fca1c9cdeb70c95154f20011b268d4d080a4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 07:41:31 +0200 Subject: rename "secure" config setting to "securityLevel" --- data/config.default.php | 2 +- www/www-security.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'data/config.default.php') diff --git a/data/config.default.php b/data/config.default.php index da16241..0c9ec69 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -13,7 +13,7 @@ $GLOBALS['phorkie']['cfg'] = array( 'index' => 'new'//"new" or "list" ); $GLOBALS['phorkie']['auth'] = array( - 'secure' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = use authentication + 'securityLevel' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = require authentication 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate 'anonymousName' => 'Anonymous', // Email for non-authenticated commits 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits diff --git a/www/www-security.php b/www/www-security.php index 9fae87b..e9fdab7 100644 --- a/www/www-security.php +++ b/www/www-security.php @@ -4,12 +4,12 @@ namespace phorkie; * security levels + login requirement: */ -if (!isset($GLOBALS['phorkie']['auth']['secure'])) { +if (!isset($GLOBALS['phorkie']['auth']['securityLevel'])) { //not set? highest level of security - $GLOBALS['phorkie']['auth']['secure'] = 2; + $GLOBALS['phorkie']['auth']['securityLevel'] = 2; } -if ($GLOBALS['phorkie']['auth']['secure'] == 0) { +if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) { //everyone may do everything return; } @@ -26,7 +26,7 @@ if (!isset($_SESSION['identity'])) { $logged_in = true; } -if ($secureAtLevel >= $GLOBALS['phorkie']['auth']['secure']) { +if ($secureAtLevel >= $GLOBALS['phorkie']['auth']['securityLevel']) { if ($logged_in) { return; } -- cgit v1.2.3 From 8aa0b9bda25f570e591e554bdbece99d5f6458c8 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 18 Sep 2012 07:46:49 +0200 Subject: rename auth configuration variables to make them more readable --- data/config.default.php | 9 ++++++--- data/config.php.dist | 5 ++++- www/www-security.php | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'data/config.default.php') diff --git a/data/config.default.php b/data/config.default.php index 0c9ec69..a0270b5 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -13,10 +13,13 @@ $GLOBALS['phorkie']['cfg'] = array( 'index' => 'new'//"new" or "list" ); $GLOBALS['phorkie']['auth'] = array( - 'securityLevel' => 0, // 0 = public, no authentication, 1 = protect adds/edits/deletes, 2 = require authentication - 'userlist' => false, // true = user must be explicitly defined, false = anyone allowed, but they must authenticate + // 0 = public, no authentication, 1 = protect adds/edits/deletes, + // 2 = require authentication + 'securityLevel' => 0, + 'listedUsersOnly' => false, + 'users' => array(), // Array of OpenIDs that may login 'anonymousName' => 'Anonymous', // Email for non-authenticated commits - 'anonymousEmail' => 'anonymous@phorkie' // Email for non-authenticated commits + 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, diff --git a/data/config.php.dist b/data/config.php.dist index e90f704..ced993f 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -5,7 +5,10 @@ //$GLOBALS['phorkie']['cfg']['git']['private'] = 'ssh://git@bogo:paste/'; //$GLOBALS['phorkie']['cfg']['elasticsearch'] = 'http://localhost:9200/phorkie/'; //$GLOBALS['phorkie']['cfg']['setupcheck'] = false; -//$GLOBALS['phorkie']['users'] = array( + +//$GLOBALS['phorkie']['auth']['securityLevel'] = 0; +//$GLOBALS['phorkie']['auth']['listedUsersOnly'] = false; +//$GLOBALS['phorkie']['auth']['users'] = array( // 'https://www.google.com/accounts/o8/id?id=ABCDEFGHIJKLMNOPQRSTUVWXYZ', // 'http://anonymous.phorkie.openid' //); diff --git a/www/www-security.php b/www/www-security.php index e9fdab7..ccbdb97 100644 --- a/www/www-security.php +++ b/www/www-security.php @@ -17,8 +17,8 @@ if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) { $logged_in = false; if (!isset($_SESSION['identity'])) { //not logged in -} else if ($GLOBALS['phorkie']['auth']['userlist']) { - if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['users'])) { +} else if ($GLOBALS['phorkie']['auth']['listedUsersOnly']) { + if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['auth']['users'])) { $logged_in = true; } } else { -- cgit v1.2.3 From a1bceaf02f8f8a3fdbb8042ffcfab4b3a35f14f7 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 18 Sep 2012 06:51:56 -0400 Subject: CLEAN: Corrected spacing --- data/config.default.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data/config.default.php') diff --git a/data/config.default.php b/data/config.default.php index a0270b5..a087767 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -17,9 +17,9 @@ $GLOBALS['phorkie']['auth'] = array( // 2 = require authentication 'securityLevel' => 0, 'listedUsersOnly' => false, - 'users' => array(), // Array of OpenIDs that may login - 'anonymousName' => 'Anonymous', // Email for non-authenticated commits - 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits + 'users' => array(), // Array of OpenIDs that may login + 'anonymousName' => 'Anonymous', // Email for non-authenticated commits + 'anonymousEmail' => 'anonymous@phorkie', // Email for non-authenticated commits ); $GLOBALS['phorkie']['tools'] = array( '\\phorkie\\Tool_Xmllint' => true, -- cgit v1.2.3 From d316adab970b993504ba38736a0f8753ef4bb052 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Tue, 18 Sep 2012 15:25:47 -0400 Subject: Feature: Add Markdown parsing --- ChangeLog | 4 ++++ README.rst | 3 +++ data/config.default.php | 5 +++++ src/phorkie/Renderer/Markdown.php | 27 +++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 src/phorkie/Renderer/Markdown.php (limited to 'data/config.default.php') diff --git a/ChangeLog b/ChangeLog index afefa9a..8557be7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-09-18 Justin J. Novack + + * Add Markdown as a known file-type. + 2012-09-16 Christian Weiske * Implement request #12: DOAP documents for all pastes diff --git a/README.rst b/README.rst index d1c6491..4a157bf 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,9 @@ phorkie stands on the shoulders of giants. $ pear channel-discover zustellzentrum.cweiske.de $ pear install zz/mime_type_plaindetect-alpha + $ pear channel-discover pear.michelf.ca + $ pear install michelf/Markdown + Note that this version of GeSHi is a bit outdated, but it's the fastest way to install it. diff --git a/data/config.default.php b/data/config.default.php index 88c9ae5..3fc48f6 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -57,6 +57,11 @@ $GLOBALS['phorkie']['languages'] = array( 'mime' => 'application/javascript', 'geshi' => 'javascript' ), + 'md' => array( + 'title' => 'Markdown', + 'mime' => 'text/x-markdown', + 'renderer' => '\\phorkie\\Renderer_Markdown' + ), 'pl' => array( 'title' => 'Perl', 'mime' => 'application/x-perl', diff --git a/src/phorkie/Renderer/Markdown.php b/src/phorkie/Renderer/Markdown.php new file mode 100644 index 0000000..628d87f --- /dev/null +++ b/src/phorkie/Renderer/Markdown.php @@ -0,0 +1,27 @@ +getContent()); + + return '
' + . $markdown + . '
'; + } +} + +?> -- cgit v1.2.3