diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -436,6 +436,7 @@ 'ConpherenceViewController' => 'applications/conpherence/controller/ConpherenceViewController.php', 'CountdownEditConduitAPIMethod' => 'applications/countdown/conduit/CountdownEditConduitAPIMethod.php', 'CountdownSearchConduitAPIMethod' => 'applications/countdown/conduit/CountdownSearchConduitAPIMethod.php', + 'CowsayReferenceController' => 'applications/reference/src/controller/CowsayReferenceController.php', 'DarkConsoleController' => 'applications/console/controller/DarkConsoleController.php', 'DarkConsoleCore' => 'applications/console/core/DarkConsoleCore.php', 'DarkConsoleDataController' => 'applications/console/controller/DarkConsoleDataController.php', @@ -1304,6 +1305,7 @@ 'FeedStoryNotificationGarbageCollector' => 'applications/notification/garbagecollector/FeedStoryNotificationGarbageCollector.php', 'FerretConfigurableSearchFunction' => 'applications/search/ferret/function/FerretConfigurableSearchFunction.php', 'FerretSearchFunction' => 'applications/search/ferret/function/FerretSearchFunction.php', + 'FigletReferenceController' => 'applications/reference/src/controller/FigletReferenceController.php', 'FileAllocateConduitAPIMethod' => 'applications/files/conduit/FileAllocateConduitAPIMethod.php', 'FileConduitAPIMethod' => 'applications/files/conduit/FileConduitAPIMethod.php', 'FileCreateMailReceiver' => 'applications/files/mail/FileCreateMailReceiver.php', @@ -5878,7 +5880,11 @@ 'ProjectSearchConduitAPIMethod' => 'applications/project/conduit/ProjectSearchConduitAPIMethod.php', 'QueryFormattingTestCase' => 'infrastructure/storage/__tests__/QueryFormattingTestCase.php', 'QueryFuture' => 'infrastructure/storage/future/QueryFuture.php', + 'ReferenceApplication' => 'applications/reference/src/application/ReferenceApplication.php', + 'ReferenceController' => 'applications/reference/src/controller/ReferenceController.php', 'RemarkupProcessConduitAPIMethod' => 'applications/remarkup/conduit/RemarkupProcessConduitAPIMethod.php', + 'RemarkupReferenceController' => 'applications/reference/src/controller/RemarkupReferenceController.php', + 'RemarkupSyntaxDocumentationProvider' => 'infrastructure/markup/interface/RemarkupSyntaxDocumentationProvider.php', 'RemarkupValue' => 'applications/remarkup/RemarkupValue.php', 'RepositoryConduitAPIMethod' => 'applications/repository/conduit/RepositoryConduitAPIMethod.php', 'RepositoryQueryConduitAPIMethod' => 'applications/repository/conduit/RepositoryQueryConduitAPIMethod.php', @@ -6444,6 +6450,7 @@ 'ConpherenceViewController' => 'ConpherenceController', 'CountdownEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'CountdownSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', + 'CowsayReferenceController' => 'ReferenceController', 'DarkConsoleController' => 'PhabricatorController', 'DarkConsoleCore' => 'Phobject', 'DarkConsoleDataController' => 'PhabricatorController', @@ -7404,6 +7411,7 @@ 'FeedStoryNotificationGarbageCollector' => 'PhabricatorGarbageCollector', 'FerretConfigurableSearchFunction' => 'FerretSearchFunction', 'FerretSearchFunction' => 'Phobject', + 'FigletReferenceController' => 'ReferenceController', 'FileAllocateConduitAPIMethod' => 'FileConduitAPIMethod', 'FileConduitAPIMethod' => 'ConduitAPIMethod', 'FileCreateMailReceiver' => 'PhabricatorApplicationMailReceiver', @@ -11211,12 +11219,18 @@ 'PhabricatorRegistrationProfile' => 'Phobject', 'PhabricatorRemarkupCachePurger' => 'PhabricatorCachePurger', 'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl', - 'PhabricatorRemarkupCowsayBlockInterpreter' => 'PhutilRemarkupBlockInterpreter', + 'PhabricatorRemarkupCowsayBlockInterpreter' => array( + 'PhutilRemarkupBlockInterpreter', + 'RemarkupSyntaxDocumentationProvider', + ), 'PhabricatorRemarkupCustomBlockRule' => 'PhutilRemarkupBlockRule', 'PhabricatorRemarkupCustomInlineRule' => 'PhutilRemarkupRule', 'PhabricatorRemarkupDocumentEngine' => 'PhabricatorDocumentEngine', 'PhabricatorRemarkupEditField' => 'PhabricatorEditField', - 'PhabricatorRemarkupFigletBlockInterpreter' => 'PhutilRemarkupBlockInterpreter', + 'PhabricatorRemarkupFigletBlockInterpreter' => array( + 'PhutilRemarkupBlockInterpreter', + 'RemarkupSyntaxDocumentationProvider', + ), 'PhabricatorRemarkupHyperlinkEngineExtension' => 'PhutilRemarkupHyperlinkEngineExtension', 'PhabricatorRemarkupUIExample' => 'PhabricatorUIExample', 'PhabricatorRemoveEmailUserLogType' => 'PhabricatorUserLogType', @@ -12793,7 +12807,10 @@ 'ProjectSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'QueryFormattingTestCase' => 'PhabricatorTestCase', 'QueryFuture' => 'Future', + 'ReferenceApplication' => 'PhabricatorApplication', + 'ReferenceController' => 'PhabricatorController', 'RemarkupProcessConduitAPIMethod' => 'ConduitAPIMethod', + 'RemarkupReferenceController' => 'ReferenceController', 'RemarkupValue' => 'Phobject', 'RepositoryConduitAPIMethod' => 'ConduitAPIMethod', 'RepositoryQueryConduitAPIMethod' => 'RepositoryConduitAPIMethod', diff --git a/src/applications/reference/src/application/ReferenceApplication.php b/src/applications/reference/src/application/ReferenceApplication.php new file mode 100644 --- /dev/null +++ b/src/applications/reference/src/application/ReferenceApplication.php @@ -0,0 +1,27 @@ + array( + 'remarkup/' => 'RemarkupReferenceController', + 'cowsay/' => 'CowsayReferenceController', + 'figlet/' => 'FigletReferenceController', + ), + ); + } + +} diff --git a/src/applications/reference/src/controller/CowsayReferenceController.php b/src/applications/reference/src/controller/CowsayReferenceController.php new file mode 100644 --- /dev/null +++ b/src/applications/reference/src/controller/CowsayReferenceController.php @@ -0,0 +1,43 @@ +getRequest(); + $viewer = $request->getViewer(); + + $content = $this->getContent(); + + $remarkup_view = id(new PHUIRemarkupView($viewer, $content)) + ->setContextObject($this) + ->setRemarkupOption(PHUIRemarkupView::OPTION_GENERATE_TOC, true) + ->setGenerateTableOfContents(true); + + $content = $remarkup_view->render(); + + $toc = $remarkup_view->getTableOfContents(); + $toc = $this->getToc($toc); + + $document = id(new PHUIDocumentView()) + ->addClass('reference-documentation') + ->setToc($toc) + ->appendChild($remarkup_view); + + $crumbs = $this->buildApplicationCrumbs(); + + return $this->newPage() + ->setTitle($this->getTitle()) + ->setCrumbs($crumbs) + ->appendChild($document); + } + + protected function buildApplicationCrumbs() { + $crumbs = array(); + + $application = $this->getCurrentApplication(); + if ($application) { + $icon = $application->getIcon(); + if (!$icon) { + $icon = 'fa-puzzle'; + } + + $crumbs[] = id(new PHUICrumbView()) + ->setName($this->getTitle()) + ->setIcon($icon); + } + + $view = new PHUICrumbsView(); + foreach ($crumbs as $crumb) { + $view->addCrumb($crumb); + } + + return $view; + } + + protected function getToc($toc) { + + if ($toc) { + $toc = phutil_tag_div('phui-document-toc-content', array( + phutil_tag_div( + 'phui-document-toc-header', + pht('Contents')), + $toc, + )); + } + + return $toc; + } +} diff --git a/src/applications/reference/src/controller/RemarkupReferenceController.php b/src/applications/reference/src/controller/RemarkupReferenceController.php new file mode 100644 --- /dev/null +++ b/src/applications/reference/src/controller/RemarkupReferenceController.php @@ -0,0 +1,762 @@ + Quoted Text + + Use `- ` or `* ` for bulleted lists, and `# ` for numbered lists. + Use ``` or indent two spaces for code. + Use %%% for a literal block. + Use | ... | ... for tables. + += Basic Styling = + +Format **basic text styles** like this: + + **bold text** + //italic text// + `monospaced text` + ##monospaced text## + ~~deleted text~~ + __underlined text__ + !!highlighted text!! + +Those produce **bold text**, //italic text//, `monospaced text`, ##monospaced +text##, ~~deleted text~~, __underlined text__, and !!highlighted text!! +respectively. + += Layout = + +Make **headers** like this: + + = Large Header = + + == Smaller Header == + + ===== Very Small Header ===== + + Alternate Large Header + ====================== + + Alternate Smaller Header + ------------------------ + +You can optionally omit the trailing `=` signs -- that is, these are the same: + + == Smaller Header == + + == Smaller Header + +This produces headers like the ones in this document. Make sure you have an +empty line before and after the header. + +Lists +===== + +Make **lists** by beginning each item with a `-` or a `*`: + + lang=text + - milk + - eggs + - bread + + * duck + * duck + * goose + +This produces a list like this: + + - milk + - eggs + - bread + +(Note that you need to put a space after the `-` or `*`.) + +You can make numbered lists with a `#` instead of `-` or `*`: + + # Articuno + # Zapdos + # Moltres + +Numbered lists can also be started with `1.` or `1)`. If you use a number other +than `1`, the list will start at that number instead. For example, this: + +``` + 200) OK + 201) Created + 202) Accepted +``` + +...produces this: + + 200) OK + 201) Created + 202) Accepted + +You can also nest lists: + +```- Body + - Head + - Arm + - Elbow + - Hand + # Thumb + # Index + # Middle + # Ring + # Pinkie + - Leg + - Knee + - Foot``` + +...which produces: + + - Body + - Head + - Arm + - Elbow + - Hand + # Thumb + # Index + # Middle + # Ring + # Pinkie + - Leg + - Knee + - Foot + +If you prefer, you can indent lists using multiple characters to show indent +depth, like this: + +```- Tree +-- Branch +--- Twig``` + +As expected, this produces: + +- Tree +-- Branch +--- Twig + +You can add checkboxes to items by prefacing them with `[ ]` or `[X]`, like +this: + +``` + - [X] Preheat oven to 450 degrees. + - [ ] Zest 35 lemons. +``` + +When rendered, this produces: + + - [X] Preheat oven to 450 degrees. + - [ ] Zest 35 lemons. + +Code Blocks +=========== + +Make **code blocks** by indenting two spaces: + + f(x, y); + +You can also use three backticks to enclose the code block: + + ```f(x, y); + g(f);``` + +You can specify a language for syntax highlighting with `lang=xxx`: + + lang=text + lang=html + ... + +When using fenced code blocks (triple backticks) you can simply append the +language right after the backticks, like this: ##```html## + +This will highlight the block using a highlighter for that language, if one is +available (in most cases, this means you need to configure Pygments): + + lang=html + ... + +You can also use a `COUNTEREXAMPLE` header to show that a block of code is +bad and shouldn't be copied: + + lang=text + COUNTEREXAMPLE + function f() { + global \$\$variable_variable; + } + +This produces a block like this: + + COUNTEREXAMPLE + function f() { + global \$\$variable_variable; + } + +You can use `lines=N` to limit the vertical size of a chunk of code, and +`name=some_name.ext` to give it a name. For example, this: + + lang=text + lang=html, name=example.html, lines=12, counterexample + ... + +...produces this: + + lang=html, name=example.html, lines=12, counterexample +
Apple
+Apricot
+Avocado
+Banana
+Bilberry
+Blackberry
+Blackcurrant
+Blueberry
+Currant
+Cherry
+Cherimoya
+Clementine
+Date
+Damson
+Durian
+Eggplant
+Elderberry
+Feijoa
+Gooseberry
+Grape
+Grapefruit
+Guava
+Huckleberry
+Jackfruit
+Jambul
+Kiwi fruit
+Kumquat
+Legume
+Lemon
+Lime
+Lychee
+Mandarine
+Mango
+Mangostine
+Melon
+ + +You can use the `NOTE:`, `WARNING:` or `IMPORTANT:` elements to call attention +to an important idea. + +For example, write this: + +``` +NOTE: Best practices in proton pack operation include not crossing the streams. +``` + +...to produce this: + +NOTE: Best practices in proton pack operation include not crossing the streams. + +Using `WARNING:` or `IMPORTANT:` at the beginning of the line changes the +color of the callout: + +WARNING: Crossing the streams can result in total protonic reversal! + +IMPORTANT: Don't cross the streams! + +In addition, you can use `(NOTE)`, `(WARNING)`, or `(IMPORTANT)` to get the +same effect but without `(NOTE)`, `(WARNING)`, or `(IMPORTANT)` appearing in +the rendered result. For example, this callout uses `(NOTE)`: + +(NOTE) Dr. Egon Spengler is the best resource for additional proton pack + questions. + + +Dividers +======== + +You can divide sections by putting three or more dashes on a line by +themselves. This creates a divider or horizontal rule similar to an `Fruit | +Color | +Price | +Peel? | +
---|---|---|---|
Apple | +red | +`\$0.93` | +no | +
Banana | +yellow | +`\$0.19` | +**YES** | +
Fruit | +Color | +Price | +Peel? | +
---|---|---|---|
Apple | +red | +`\$0.93` | +no | +
Banana | +yellow | +`\$0.19` | +**YES** | +