Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added api/languages endpoint

- Provides a list of languages that may be used to create new pastes
  • Loading branch information...
commit fa228ad74e32e030a6ac7c16d69a39643169338a 1 parent 5ab1275
@weierophinney weierophinney authored
View
9 config/module.config.php
@@ -142,6 +142,15 @@
),
'may_terminate' => true,
'child_routes' => array(
+ 'languages' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/languages',
+ 'defaults' => array(
+ 'action' => 'languages',
+ ),
+ ),
+ ),
'item' => array(
'type' => 'Segment',
'options' => array(
View
16 src/PhlyPaste/Controller/ApiController.php
@@ -54,6 +54,22 @@ public function onDispatch(MvcEvent $e)
return parent::onDispatch($e);
}
+ public function languagesAction()
+ {
+ $request = $this->getRequest();
+ if (!$request->isGet()) {
+ return $this->createError('invalid-method');
+ }
+ $form = $this->formFactory->factory();
+ $element = $form->get('language');
+ $options = $element->getValueOptions();
+ $languages = array_keys($options);
+ $model = new JsonModel(array(
+ 'languages' => $languages,
+ ));
+ return $model;
+ }
+
public function listAction()
{
$request = $this->getRequest();
View
31 view/phly-paste/paste/help.phtml
@@ -169,6 +169,37 @@ Content-Type: application/json
]
}
</pre>
+
+ <h3>GET /paste/api/languages</h3>
+
+ <p>
+ Returns a list of language strings that may be used when creating a paste.
+ </p>
+
+ <pre>
+HTTP/1.0 200 Ok
+Content-Type: application/json
+
+{
+ "languages": [
+ "apache",
+ "diff",
+ "html4strict",
+ "ini",
+ "javascript",
+ "jquery",
+ "markdown",
+ "php",
+ "text",
+ "python",
+ "ruby",
+ "bash",
+ "sql",
+ "vim",
+ "xml"
+ ]
+}
+ </pre>
</div>
<?php echo $this->render('phly-paste/paste/sidebar'); ?>
Please sign in to comment.
Something went wrong with that request. Please try again.