Last active
November 21, 2022 20:15
-
-
Save lazyandreal/6f5cc9755f86b822a38cbd911a116b66 to your computer and use it in GitHub Desktop.
Wiki stack scaffolding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = () => layout(html` | |
<h3>Add a Page</h3> | |
<hr> | |
<form method="POST" action="/wiki/"> | |
<div>PLACEHOLDER FOR AUTHOR NAME FIELD</div> | |
<div>PLACEHOLDER FOR AUTHOR EMAIL FIELD</div> | |
<div class="form-group"> | |
<label for="title" class="col-sm-2 control-label">Page Title</label> | |
<div class="col-sm-10"> | |
<input id="title" name="title" type="text" class="form-control"/> | |
</div> | |
</div> | |
<div>PLACEHOLDER FOR PAGE CONTENT TEXTAREA FIELD</div> | |
<div>PLACEHOLDER FOR PAGE STATUS INPUT FIELD</div> | |
<div class="col-sm-offset-2 col-sm-10"> | |
<button type="submit" class="btn btn-primary">submit</button> | |
</div> | |
</form> | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = (page, author) => layout(html` | |
<h3>Edit a Page</h3> | |
<hr> | |
<form method="POST" action="/wiki/${page.slug}"> | |
<div>PLACEHOLDER FOR AUTHOR NAME FIELD</div> | |
<div>PLACEHOLDER FOR AUTHOR EMAIL FIELD</div> | |
<div class="form-group"> | |
<label for="title" class="col-sm-2 control-label">Page Title</label> | |
<div class="col-sm-10"> | |
<input name="title" type="text" class="form-control" value="${page.title}"/> | |
</div> | |
</div> | |
<div>PLACEHOLDER FOR PAGE CONTENT TEXTAREA FIELD</div> | |
<div class="form-group"> | |
<label for="content" class="col-sm-2 control-label">Status</label> | |
<div class="col-sm-10"> | |
<select name="status"> | |
<option ${page.status == "open" ? "selected" : ""}>open</option> | |
<option ${page.status == "closed" ? "selected" : ""}>closed</option> | |
</select> | |
</div> | |
</div> | |
<div class="col-sm-offset-2 col-sm-10"> | |
<button type="submit" class="btn btn-primary">submit</button> | |
</div> | |
</form> | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addPage = require("./addPage"); | |
const editPage = require("./editPage"); | |
const main = require("./main"); | |
const userList = require("./userList"); | |
const userPages = require("./userPages"); | |
const wikiPage = require("./wikiPage"); | |
module.exports = { addPage, editPage, main, userList, userPages, wikiPage }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
module.exports = (content) => html`<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>WikiStack</title> | |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="/stylesheets/style.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="navbar navbar-fixed-top navbar-inverse" role="navigation"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-items"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a class="navbar-brand" href="/wiki">wikistack</a> | |
</div> | |
<div id="nav-items" class="collapse navbar-collapse"> | |
<ul class="nav navbar-nav"> | |
<li><a href="/wiki/">index</a></li> | |
<li><a href="/wiki/add">write</a></li> | |
<li><a href="/users">users</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<div class="container content"> | |
$${content} | |
</div> | |
<hr/> | |
<div id="footer" class="container text-muted"> | |
WIKISTACK by Fullstack Academy | |
</div> | |
</body> | |
</html>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = (pages) => layout(html` | |
<h3>Pages</h3> | |
<hr> | |
<form method="GET" action="/wiki/search"> | |
<input type="text" name="search" /> | |
<button type="submit">Search</button> | |
</form> | |
<hr> | |
<ul class="list-unstyled"> | |
<ul> | |
<!-- PLACEHOLDER LIST OF PAGES --> | |
</ul> | |
</ul>`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = (users) => layout(html` | |
<h3>Users</h3> | |
<hr> | |
<ul class="list-unstyled"> | |
<ul> | |
${users.map(user => html`<li> | |
<a href="/users/${user.id}">${user.name}</a> | |
</li>`)} | |
</ul> | |
</ul> | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = (user, pages) => layout(html` | |
<h3>Pages written by ${user.name}</h3> | |
<hr> | |
<form method="GET" action="/wiki/search"> | |
<input type="text" name="search" /> | |
<button type="submit">Search</button> | |
</form> | |
<hr> | |
<ul class="list-unstyled"> | |
<ul> | |
${pages.map(page => html`<li><a href="/wiki/${page.slug}">${page.title}</a></li>`)} | |
</ul> | |
</ul> | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const html = require("html-template-tag"); | |
const layout = require("./layout"); | |
module.exports = (page, author) => layout(html` | |
<h3>${page.title} | |
<small> (<a href="/wiki/${page.slug}/similar">Similar</a>)</small> | |
</h3> | |
<h4>by <a href="PLACEHOLDER-AUTHOR-URL">PLACEHOLDER AUTHOR NAME</a></h4> | |
<hr/> | |
<div class="page-body">${page.content}</div> | |
<hr/> | |
<a href="/wiki/${page.slug}/edit" class="btn btn-primary">edit this page</a> | |
<a href="/wiki/${page.slug}/delete" class="btn btn-danger">delete this page</a> | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment