Initial Commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
const moment = require("moment")
|
||||
|
||||
module.exports = class {
|
||||
onCreate({kind, weak, value, updated}) {
|
||||
this.state = {text: null, color: "color-menu", href: null, tooltip: null}
|
||||
|
||||
if (value == null || value == "") {
|
||||
return
|
||||
}
|
||||
|
||||
switch (kind) {
|
||||
case "date": {
|
||||
const m = moment(value)
|
||||
if (m.year() < 2) {
|
||||
break
|
||||
}
|
||||
|
||||
if (!weak) {
|
||||
this.state.tooltip = `See all stories set during ${m.format("MMMM YYYY")}`
|
||||
this.state.href = `/story/by-month/${m.format("YYYY-MM")}/`
|
||||
}
|
||||
|
||||
const dateStr = m.format("MMM D, YYYY")
|
||||
|
||||
this.state.text = dateStr
|
||||
|
||||
if (updated != null && Date.parse(updated) > Date.parse(value)) {
|
||||
const m2 = moment(updated)
|
||||
this.state.tooltip = "Originally posted: " + dateStr
|
||||
this.state.text = m2.format("MMM D, YYYY") + " *"
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
case "author": {
|
||||
this.state.text = value
|
||||
this.state.tooltip = "See all stories by " + value
|
||||
this.state.href = `/story/by-author/${value}/`
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
this.state.color = "color-menu"
|
||||
this.state.text = value
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<if(state.text != null && state.text != "")>
|
||||
<div class=["chapter-meta", input.kind, state.color, input.weak ? "weak" : null] title=state.tooltip>
|
||||
<a if(state.href != null) href=state.href>${state.text}</a>
|
||||
<span else>${state.text}</span>
|
||||
</div>
|
||||
</if>
|
||||
@@ -0,0 +1,20 @@
|
||||
div.chapter-meta {
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
padding-right: 1em;
|
||||
margin: 0;
|
||||
|
||||
user-select: none;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
border-bottom: 0.25px dotted;
|
||||
}
|
||||
a:hover {
|
||||
border-bottom: 0.5px solid;
|
||||
}
|
||||
}
|
||||
|
||||
div.chapter-meta.weak {
|
||||
opacity: 0.5;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = class {
|
||||
onCreate(input) {
|
||||
this.state = Object.assign({}, input.chapter)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="story-chapter">
|
||||
<a class="anchor" id=state.id />
|
||||
<div class="metadata">
|
||||
<chapter-meta kind="title" value=state.title />
|
||||
<chapter-meta kind="date" value=state.fictionalDate />
|
||||
<chapter-meta weak kind="date" value=state.createdDate />
|
||||
<chapter-meta weak kind="author" value=state.author />
|
||||
</div>
|
||||
<markdown class="chapter-content" source=state.source />
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
.story-chapter {
|
||||
padding-bottom: 1em;
|
||||
|
||||
.metadata {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a.anchor {
|
||||
display: block;
|
||||
position: relative;
|
||||
top: -8em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<story-content-menu story=input.story selected=(input.selected || {}) user=input.user />
|
||||
<main>
|
||||
<div class="story-content">
|
||||
<h1 class="color-primary">${input.story.name}</h1>
|
||||
<story-tags tags=input.story.tags />
|
||||
<chapter for(chapter in input.story.chapters) key=chapter.id chapter=chapter />
|
||||
</div>
|
||||
</main>
|
||||
@@ -0,0 +1,9 @@
|
||||
.story-content {
|
||||
width: 90%;
|
||||
max-width: 75ch;
|
||||
margin: auto;
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
const moment = require("moment")
|
||||
|
||||
module.exports = class {
|
||||
onCreate(input) {
|
||||
this.state = {
|
||||
chapterTitles: {},
|
||||
fdateLink: "",
|
||||
fdate: "",
|
||||
selectedChapter: ""
|
||||
}
|
||||
}
|
||||
|
||||
onMount() {
|
||||
this.state.selectedChapter = (window.location.hash||"#").slice(1)
|
||||
}
|
||||
|
||||
onInput(input) {
|
||||
if (input.story.fictionalDate && input.story.fictionalDate.getUTCFullYear() > 10) {
|
||||
const fdate = input.story.fictionalDate
|
||||
|
||||
this.state.fdateLink = `/story/by-month/${moment(fdate).format("YYYY-MM")}`
|
||||
this.state.fdate = moment(fdate).format("MMM D, YYYY")
|
||||
}
|
||||
|
||||
for (const chapter of input.story.chapters) {
|
||||
let title = "Chapter " + input.story.chapters.indexOf(chapter) + 1
|
||||
if (chapter.title) {
|
||||
title = chapter.title
|
||||
} else if (chapter.fictionalDate && chapter.fictionalDate.getUTCFullYear() > 1) {
|
||||
title = moment(chapter.fictionalDate).format("MMM D, YYYY")
|
||||
}
|
||||
|
||||
this.state.chapterTitles[chapter.id] = title
|
||||
}
|
||||
}
|
||||
|
||||
selectChapter(id) {
|
||||
this.state.selectedChapter = id
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<menu user=input.user>
|
||||
<if(input.story.chapters.length > 1)>
|
||||
<menu-header>${input.story.name}</menu-header>
|
||||
<for(chapter in input.story.chapters | status-var=loop)>
|
||||
<menu-link on-click("selectChapter", chapter.id) href=("#" + chapter.id) selected=(state.selectedChapter === chapter.id) icon=(loop.getIndex()+1)>${state.chapterTitles[chapter.id]}</menu-link>
|
||||
</for>
|
||||
<menu-gap />
|
||||
</if>
|
||||
</menu>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="story-tags">
|
||||
<a for(tag in input.tags) href=("/story/by-tag/" + tag.kind + "/" + encodeURIComponent(tag.name)) class=["tag", "color-tag-" + tag.kind.toLowerCase()]>${tag.name}</a>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
div.story-tags {
|
||||
text-align: center;
|
||||
margin-bottom: 1em;
|
||||
margin-top: -1em;
|
||||
|
||||
a.tag {
|
||||
display: inline-block;
|
||||
margin: 0.5em 0.5ch;
|
||||
padding: 0.0625em 0.5ch;
|
||||
|
||||
outline: 1px solid;
|
||||
opacity: 0.75;
|
||||
|
||||
user-select: none;
|
||||
}
|
||||
a.tag:hover {
|
||||
opacity: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<include("../layout", {title: "Stories", site: "story"})>
|
||||
<@body>
|
||||
<background src="/assets/images/bg.png" opacity=0.25 />
|
||||
<page story=input.story user=input.user selected=input.selected />
|
||||
</@body>
|
||||
</include>
|
||||
Reference in New Issue
Block a user