Browse Source

Added help info for Paste API.

tags/2.0.3
Teknikode 4 years ago
parent
commit
e26d5333c2

+ 2
- 2
Teknik/Areas/API/Controllers/APIv1Controller.cs View File

@@ -123,11 +123,11 @@ namespace Teknik.Areas.API.Controllers

[HttpPost]
[AllowAnonymous]
public ActionResult Paste(string content, string title = "", string syntax = "auto", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false)
public ActionResult Paste(string code, string title = "", string syntax = "auto", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false)
{
try
{
Paste.Models.Paste paste = PasteHelper.CreatePaste(content, title, syntax, expireUnit, expireLength, password, hide);
Paste.Models.Paste paste = PasteHelper.CreatePaste(code, title, syntax, expireUnit, expireLength, password, hide);

db.Pastes.Add(paste);
db.SaveChanges();

+ 1
- 0
Teknik/Areas/Help/Views/Help/API/API.cshtml View File

@@ -10,6 +10,7 @@
<p>
<ul class="list-unstyled">
<li><a href="@Url.SubRouteUrl("help", "Help.API", new { version = "v1", service = "Upload" })">Upload Service</a></li>
<li><a href="@Url.SubRouteUrl("help", "Help.API", new { version = "v1", service = "Paste" })">Paste Service</a></li>
</ul>
</p>
</div>

+ 219
- 0
Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml View File

@@ -0,0 +1,219 @@
@model Teknik.Areas.Help.ViewModels.HelpViewModel

@using Teknik.Helpers

@Styles.Render("~/Content/help");

<div class="container">
<div class="row api">
<h2><b>Paste</b></h2>
<hr>
<p>This is a description of the API commands available for the Paste service.</p>
<h3>Submit a Paste</h3>
<pre><code>POST @Url.SubRouteUrl("api", "API.v1.Paste")</code></pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>code</code>
</td>
<td>
<code>string</code>
</td>
<td>
<var>NULL</var>
</td>
<td>
<strong>Required</strong>
The text that will be submitted as the paste content.
</td>
</tr>
<tr>
<td>
<code>title</code>
</td>
<td>
<code>string</code>
</td>
<td>
<var>NULL</var>
</td>
<td>
The title for the paste.
</td>
</tr>
<tr>
<td>
<code>syntax</code>
</td>
<td>
<code>string</code>
</td>
<td>
auto-detect
</td>
<td>
The syntax of the pasted code.
<br />
This can be one of the following:
<select name="format" class="selectpicker">
@foreach (KeyValuePair<string, string> format in Constants.HIGHLIGHTFORMATS)
{
<option value="@format.Value">@format.Key</option>
}
</select>
</td>
</tr>
<tr>
<td>
<code>expireUnit</code>
</td>
<td>
<code>string</code>
</td>
<td>
<var>never</var>
</td>
<td>
The expiration type for the paste. Possible values are <code>view</code> (Number of Views) or a date value <code>minute</code>, <code>hour</code>, <code>day</code>, <code>month</code>, <code>year</code>
</td>
</tr>
<tr>
<td>
<code>expireLength</code>
</td>
<td>
<code>int</code>
</td>
<td>
<var>1</var>
</td>
<td>
The length of whatever unit you choose before the paste is deleted.
</td>
</tr>
<tr>
<td>
<code>password</code>
</td>
<td>
<code>string</code>
</td>
<td>
<var>NULL</var>
</td>
<td>
Specify a password to encrypt and lock the paste with.
</td>
</tr>
<tr>
<td>
<code>hide</code>
</td>
<td>
<code>bool</code>
</td>
<td>
<var>false</var>
</td>
<td>
If the paste should be visible in the most recent pastes list.
</td>
</tr>
</tbody>
</table>
<h4>Response</h4>
<pre><code>{"result":{"id":<var>id</var> "url":"<var>url</var>", "title":"<var>title</var>", "syntax":"<var>auto-detect</var>", "expiration":"<var>datetime</var>", "password":"<var>password</var>"}}}</code></pre>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>id</code>
</td>
<td>
<code>string</code>
</td>
<td>
The id of the paste.
</td>
</tr>
<tr>
<td>
<code>url</code>
</td>
<td>
<code>string</code>
</td>
<td>
The direct url to the paste.
</td>
</tr>
<tr>
<td>
<code>title</code>
</td>
<td>
<code>string</code>
</td>
<td>
The title of the paste.
</td>
</tr>
<tr>
<td>
<code>syntax</code>
</td>
<td>
<code>string</code>
</td>
<td>
The syntax of the pasted code.
</td>
</tr>
<tr>
<td>
<code>expiration</code>
</td>
<td>
<code>datetime</code>
</td>
<td>
The date of expiration of the paste.
</td>
</tr>
<tr>
<td>
<code>password</code>
</td>
<td>
<code>string</code>
</td>
<td>
The password of the paste.
</td>
</tr>
</tbody>
</table>
<h4>Example</h4>
<pre><code>$ curl --data "title=Paste%20Title&expireUnit=view&expireLength=3" --data-urlencode "code=This%20is%20my%20test%20code." @Url.SubRouteUrl("api", "API.v1.Paste")</code></pre>
<p>
This will submit the paste with a title and expiration when the paste has viewed 3 times.
</p>
</div>
</div>

+ 1
- 1
Teknik/Areas/Paste/PasteHelper.cs View File

@@ -11,7 +11,7 @@ namespace Teknik.Areas.Paste
{
public static class PasteHelper
{
public static Models.Paste CreatePaste(string content, string title = "", string syntax = "auto", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false)
public static Models.Paste CreatePaste(string content, string title = "", string syntax = "auto-detect", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false)
{
Config config = Config.Load();
Models.Paste paste = new Models.Paste();

+ 1
- 1
Teknik/Areas/Paste/Views/Paste/Full.cshtml View File

@@ -5,7 +5,7 @@

@{
string syntax = string.Empty;
if (Model.Syntax != "auto-select")
if (Model.Syntax != "auto-detect")
{
syntax = Model.Syntax;
}

+ 1
- 1
Teknik/Areas/Paste/Views/Paste/Index.cshtml View File

@@ -33,7 +33,7 @@
<label for="syntax" class="col-sm-2 col-sm-offset-1 control-label">Syntax</label>
<div class="col-sm-4">
<select class="form-control" name="Syntax" id="syntax">
<option value="auto-select">Auto Select</option>
<option value="auto-detect">Auto Detect</option>
@foreach (KeyValuePair<string, string> format in Constants.HIGHLIGHTFORMATS)
{
<option value="@format.Value">@format.Key</option>

+ 1
- 1
Teknik/Areas/Paste/Views/Paste/Simple.cshtml View File

@@ -2,7 +2,7 @@
@{
Layout = "";
string syntax = string.Empty;
if (Model.Syntax != "auto-select")
if (Model.Syntax != "auto-detect")
{
syntax = Model.Syntax;
}

+ 1
- 0
Teknik/Teknik.csproj View File

@@ -399,6 +399,7 @@
<Content Include="Areas\Paste\Views\Paste\PasswordNeeded.cshtml" />
<Content Include="Areas\Error\Views\Error\Http403.cshtml" />
<Content Include="Areas\Paste\Views\Paste\Simple.cshtml" />
<Content Include="Areas\Help\Views\Help\API\v1\Paste.cshtml" />
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" />
<None Include="Scripts\jquery-2.1.4.intellisense.js" />
<Content Include="Scripts\bootbox\bootbox.min.js" />

Loading…
Cancel
Save