sql..
This commit is contained in:
parent
97fcdbebbd
commit
fd09bfd1d0
|
@ -1,8 +1,16 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
import db from "../../lib/sql";
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("index");
|
db.exec("select * from `languages`")
|
||||||
|
.then(rows => {
|
||||||
|
res.render("index", { languages: rows.map(r => r.name) } )
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.send(err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
|
@ -2,31 +2,31 @@ import express from "express";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
import highlight from "highlight.js";
|
import highlight from "highlight.js";
|
||||||
|
import db from "../../lib/sql";
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const data = {
|
const query = "select p.uuid, p.stamp, p.title, p.paste, l.name as language, r.uuid as reply from `pastes` as p "
|
||||||
pastes: [
|
+ "left join `languages` as l on l.id = p.lang "
|
||||||
{
|
+ "left join `pastes` as r on r.id = p.reply "
|
||||||
title: "title 01",
|
+ "order by p.id desc "
|
||||||
paste: highlight.highlightAuto("<?php\necho 'blah';\n?>").value,
|
+ "limit 5";
|
||||||
language: "PHP",
|
db.exec(query)
|
||||||
rows: "<?php\necho 'blah';\n?>".split(/\n/).length
|
.then(rows => {
|
||||||
},
|
const pastes = rows.map(r => {
|
||||||
{
|
return {
|
||||||
title: "title 02",
|
title: r.title,
|
||||||
paste: highlight.highlightAuto("blub").value,
|
uuid: r.uuid,
|
||||||
language: "Plaintext",
|
paste: highlight.highlightAuto(r.paste).value,
|
||||||
rows: "blub".split(/\n/).length
|
language: r.language,
|
||||||
},
|
desc: r.reply ? `Reply to <a href="/${r.reply}/" class="descID">/${r.reply}/</a>` : "No description.",
|
||||||
{
|
rows: r.paste.split(/\r?\n/).length
|
||||||
title: "title 03",
|
|
||||||
paste: highlight.highlightAuto("muh").value,
|
|
||||||
language: "Plaintext",
|
|
||||||
rows: "muh".split(/\n/).length
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
res.render("view", data);
|
});
|
||||||
|
res.render("view", { pastes: pastes });
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
res.render("view");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
|
@ -3,7 +3,9 @@
|
||||||
<div class="settings"><p>Description:</p><input id="desc" type="text" name="desc" value=""></div>
|
<div class="settings"><p>Description:</p><input id="desc" type="text" name="desc" value=""></div>
|
||||||
<textarea id="content" name="content"></textarea>
|
<textarea id="content" name="content"></textarea>
|
||||||
<ul class="settings">
|
<ul class="settings">
|
||||||
<li><p>Language:</p><select id="lang" name="lang"><option value="Plaintext">Plaintext</option><option value="ABAP">ABAP</option><option value="ActionScript">ActionScript</option><option value="ActionScript 3">ActionScript 3</option><option value="Ada">Ada</option><option value="ApacheConf">ApacheConf</option><option value="AppleScript">AppleScript</option><option value="Asymptote">Asymptote</option><option value="Atomo">Atomo</option><option value="autohotkey">autohotkey</option><option value="Bash">Bash</option><option value="Batchfile">Batchfile</option><option value="Befunge">Befunge</option><option value="BlitzMax">BlitzMax</option><option value="Boo">Boo</option><option value="Brainfuck">Brainfuck</option><option value="C">C</option><option value="Clojure">Clojure</option><option value="CMake">CMake</option><option value="CoffeeScript">CoffeeScript</option><option value="Common Lisp">Common Lisp</option><option value="C++">C++</option><option value="CSS">CSS</option><option value="Cython">Cython</option><option value="D">D</option><option value="Darcs Patch">Darcs Patch</option><option value="Debian Control file">Debian Control file</option><option value="Diff">Diff</option><option value="Duel">Duel</option><option value="Dylan">Dylan</option><option value="Erlang">Erlang</option><option value="Factor">Factor</option><option value="Felix">Felix</option><option value="Fortran">Fortran</option><option value="GAS">GAS</option><option value="Gettext Catalog">Gettext Catalog</option><option value="Gherkin">Gherkin</option><option value="GLSL">GLSL</option><option value="Gnuplot">Gnuplot</option><option value="Go">Go</option><option value="GoodData-CL">GoodData-CL</option><option value="Groff">Groff</option><option value="Haskell">Haskell</option><option value="haXe">haXe</option><option value="HTML">HTML</option><option value="Hybris">Hybris</option><option value="INI">INI</option><option value="Io">Io</option><option value="Ioke">Ioke</option><option value="IRC logs">IRC logs</option><option value="Java">Java</option><option value="JavaScript">JavaScript</option><option value="LLVM">LLVM</option><option value="Logtalk">Logtalk</option><option value="Lua">Lua</option><option value="Mako">Mako</option><option value="MAQL">MAQL</option><option value="Matlab">Matlab</option><option value="MiniD">MiniD</option><option value="Modelica">Modelica</option><option value="Modula-2">Modula-2</option><option value="MOOCode">MOOCode</option><option value="MuPAD">MuPAD</option><option value="MXML">MXML</option><option value="NASM">NASM</option><option value="Newspeak">Newspeak</option><option value="objdump">objdump</option><option value="Objective-C">Objective-C</option><option value="Objective-J">Objective-J</option><option value="OCaml">OCaml</option><option value="Ooc">Ooc</option><option value="Perl">Perl</option><option value="PHP">PHP</option><option value="PostScript">PostScript</option><option value="POVRay">POVRay</option><option value="Prolog">Prolog</option><option value="Properties">Properties</option><option value="Protocol Buffer">Protocol Buffer</option><option value="Python">Python</option><option value="Python 3.0 Traceback">Python 3.0 Traceback</option><option value="Python Traceback">Python Traceback</option><option value="Embedded Ragel">Embedded Ragel</option><option value="Redcode">Redcode</option><option value="S">S</option><option value="Scala">Scala</option><option value="Scheme">Scheme</option><option value="SCSS">SCSS</option><option value="Smalltalk">Smalltalk</option><option value="Smarty">Smarty</option><option value="Debian Sourcelist">Debian Sourcelist</option><option value="SQL">SQL</option><option value="SquidConf">SquidConf</option><option value="Tcl">Tcl</option><option value="Tcsh">Tcsh</option><option value="TeX">TeX</option><option value="Vala">Vala</option><option value="VB.net">VB.net</option><option value="Velocity">Velocity</option><option value="verilog">verilog</option><option value="VimL">VimL</option><option value="XML">XML</option><option value="XSLT">XSLT</option></select></li>
|
<li><p>Language:</p><select id="lang" name="lang">
|
||||||
|
{{#each this.languages}}<option value="{{this}}">{{this}}</option>{{/each}}
|
||||||
|
</select></li>
|
||||||
<li><p>Hide from recent pastes:</p><input type="checkbox" id="hidden" name="hidden"></li>
|
<li><p>Hide from recent pastes:</p><input type="checkbox" id="hidden" name="hidden"></li>
|
||||||
</ul>
|
</ul>
|
||||||
<input id="email" type="text" name="email">
|
<input id="email" type="text" name="email">
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
<div class="pasteInfo">
|
<div class="pasteInfo">
|
||||||
<p class="timestamp">15:13 - Thu 2017.06.15</p>
|
<p class="timestamp">15:13 - Thu 2017.06.15</p>
|
||||||
<p class="language"><a href="/v/lang/{{language}}">{{language}}</a></p>
|
<p class="language"><a href="/v/lang/{{language}}">{{language}}</a></p>
|
||||||
<p>Paste: <a href="/nNm/">/nNm/</a><a href="/v/id/nNm">Show related</a></p>
|
<p>Paste: <a href="/{{uuid}}/">/{{uuid}}/</a><a href="/v/id/{{uuid}}">Show related</a></p>
|
||||||
<p class="desc">{{title}}</p>
|
<p class="desc">{{{desc}}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="formatedCode">
|
<div class="formatedCode">
|
||||||
<div class="lineNumbers">
|
<div class="lineNumbers">
|
||||||
<pre class="lineNumbers">{{#times rows}}<a href="/nNm/#{{this}}" name="{{this}}">{{this}}</a>{{/times}}</pre>
|
<pre class="lineNumbers">{{#times rows}}<a href="/{{../uuid}}/#{{this}}" name="{{this}}">{{this}}</a>{{/times}}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="sourceCode">
|
<div class="sourceCode">
|
||||||
<pre>
|
<pre>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user