diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ab47959b25..74353d4215 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -469,6 +469,7 @@ phutil_register_library_map(array( 'PhabricatorRemarkupRuleMention' => 'infrastructure/markup/remarkup/markuprule/mention', 'PhabricatorRemarkupRuleObjectName' => 'infrastructure/markup/remarkup/markuprule/objectname', 'PhabricatorRemarkupRulePaste' => 'infrastructure/markup/remarkup/markuprule/paste', + 'PhabricatorRemarkupRulePhriction' => 'infrastructure/markup/remarkup/markuprule/phriction', 'PhabricatorRemarkupRuleProxyImage' => 'infrastructure/markup/remarkup/markuprule/proxyimage', 'PhabricatorRemarkupRuleYoutube' => 'infrastructure/markup/remarkup/markuprule/youtube', 'PhabricatorRepository' => 'applications/repository/storage/repository', @@ -980,6 +981,7 @@ phutil_register_library_map(array( 'PhabricatorRemarkupRuleMention' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleObjectName' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRulePaste' => 'PhabricatorRemarkupRuleObjectName', + 'PhabricatorRemarkupRulePhriction' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleProxyImage' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleYoutube' => 'PhutilRemarkupRule', 'PhabricatorRepository' => 'PhabricatorRepositoryDAO', diff --git a/src/applications/markup/engine/PhabricatorMarkupEngine.php b/src/applications/markup/engine/PhabricatorMarkupEngine.php index eeaa4a6616..36d01012dc 100644 --- a/src/applications/markup/engine/PhabricatorMarkupEngine.php +++ b/src/applications/markup/engine/PhabricatorMarkupEngine.php @@ -101,6 +101,7 @@ class PhabricatorMarkupEngine { $rules[] = new PhabricatorRemarkupRulePaste(); $rules[] = new PhabricatorRemarkupRuleImageMacro(); $rules[] = new PhabricatorRemarkupRuleMention(); + $rules[] = new PhabricatorRemarkupRulePhriction(); $custom_rule_classes = $options['custom-inline']; if ($custom_rule_classes) { diff --git a/src/applications/markup/engine/__init__.php b/src/applications/markup/engine/__init__.php index 27712754fd..58c7ea3c83 100644 --- a/src/applications/markup/engine/__init__.php +++ b/src/applications/markup/engine/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/ phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/maniphest'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/mention'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/paste'); +phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/phriction'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/proxyimage'); phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/youtube'); diff --git a/src/applications/phriction/controller/document/PhrictionDocumentController.php b/src/applications/phriction/controller/document/PhrictionDocumentController.php index 59ea1c2008..2da85b1d31 100644 --- a/src/applications/phriction/controller/document/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/document/PhrictionDocumentController.php @@ -27,6 +27,8 @@ class PhrictionDocumentController public function processRequest() { + $request = $this->getRequest(); + $slug = PhrictionDocument::normalizeSlug($this->slug); if ($slug != $this->slug) { $uri = PhrictionDocument::getSlugURI($slug); @@ -41,19 +43,62 @@ class PhrictionDocumentController $slug); if (!$document) { - $page_content = 'No content here!'; + $create_uri = '/phriction/edit/?slug='.$slug; + + $page_content = + '
'. + 'No content here!
'. + 'No document found at '.phutil_escape_html($slug).'. '. + 'You can '. + phutil_render_tag( + 'a', + array( + 'href' => $create_uri, + ), + 'create a new document').'.'. + '
'; $page_title = 'Page Not Found'; $button = phutil_render_tag( 'a', array( - 'href' => '/phriction/edit/?slug='.$slug, + 'href' => $create_uri, 'class' => 'green button', ), 'Create Page'); } else { $content = id(new PhrictionContent())->load($document->getContentID()); - $page_content = phutil_escape_html($content->getContent()); $page_title = $content->getTitle(); + + $phids = array($content->getAuthorPHID()); + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + + $age = time() - $content->getDateCreated(); + $age = floor($age / (60 * 60 * 24)); + + if ($age < 1) { + $when = 'today'; + } else if ($age == 1) { + $when = 'yesterday'; + } else { + $when = "{$age} days ago"; + } + + $byline = + '
'. + "Last updated {$when} by ". + $handles[$content->getAuthorPHID()]->renderLink().'.'. + '
'; + + $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); + + $page_content = + '
'. + $byline. + '
'. + $engine->markupText($content->getContent()). + '
'. + '
'; + $button = phutil_render_tag( 'a', array( diff --git a/src/applications/phriction/controller/document/__init__.php b/src/applications/phriction/controller/document/__init__.php index 10fdba038d..6d7452f7b7 100644 --- a/src/applications/phriction/controller/document/__init__.php +++ b/src/applications/phriction/controller/document/__init__.php @@ -7,6 +7,8 @@ phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/markup/engine'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phriction/controller/base'); phutil_require_module('phabricator', 'applications/phriction/storage/content'); phutil_require_module('phabricator', 'applications/phriction/storage/document'); diff --git a/src/applications/phriction/controller/edit/PhrictionEditController.php b/src/applications/phriction/controller/edit/PhrictionEditController.php index 06834c741d..cfa2f04658 100644 --- a/src/applications/phriction/controller/edit/PhrictionEditController.php +++ b/src/applications/phriction/controller/edit/PhrictionEditController.php @@ -58,7 +58,8 @@ class PhrictionEditController $default_title = null; if ($slug) { - $default_title = end(explode('/', trim($slug, '/'))); + $parts = explode('/', trim($slug, '/')); + $default_title = end($parts); $default_title = str_replace('_', ' ', $default_title); $default_title = ucwords($default_title); } diff --git a/src/infrastructure/markup/remarkup/markuprule/phriction/PhabricatorRemarkupRulePhriction.php b/src/infrastructure/markup/remarkup/markuprule/phriction/PhabricatorRemarkupRulePhriction.php new file mode 100644 index 0000000000..b33bc3c941 --- /dev/null +++ b/src/infrastructure/markup/remarkup/markuprule/phriction/PhabricatorRemarkupRulePhriction.php @@ -0,0 +1,52 @@ +getEngine()->storeText( + phutil_render_tag( + 'a', + array( + 'href' => $uri, + 'class' => 'phriction-link', + ), + phutil_escape_html($name))); + } + +} diff --git a/src/infrastructure/markup/remarkup/markuprule/phriction/__init__.php b/src/infrastructure/markup/remarkup/markuprule/phriction/__init__.php new file mode 100644 index 0000000000..1c70aaadfc --- /dev/null +++ b/src/infrastructure/markup/remarkup/markuprule/phriction/__init__.php @@ -0,0 +1,16 @@ +