diff --git a/server.js b/server.js
index cc59d4f..8a7666d 100644
--- a/server.js
+++ b/server.js
@@ -48,18 +48,7 @@ app.set('view engine', 'spy');
// GET
app.get('/', requireLoggedIn, (req, res) => {
- let data = {
- title: 'Home',
- disabled: '',
- message: getSavedFile(req.session.user.username)
- }
- let today = getNow().toISOString().slice(0,10)
- let latestPost = req.session.user.latest_post
- if (today === latestPost) {
- data.disabled = 'disabled'
- data.message = `Relax, ${req.session.user.username}, you have already posted today.`
- }
- res.render('index.spy', data)
+ res.render('index.spy', {title: 'Soyuz home', writeNew: getSavedFile(req.session.user.username)? 'Return to draft' : 'New'})
})
app.get('/login', (req, res) => {
@@ -70,9 +59,33 @@ app.get('/login', (req, res) => {
}
})
+app.get('/new', requireLoggedIn, (req, res) => {
+ let message = getSavedFile(req.session.user.username) || "# Title of my note"
+ let data = {
+ title: 'New post',
+ disabled: '',
+ message: message
+ }
+ let today = getNow().toISOString().slice(0,10)
+ // check whether user has already posted today
+ return getLatestPost(req.session.user.directory, true, (dateString)=> {
+ if (today === dateString) {
+ data.disabled = 'disabled'
+ data.message = `Relax, ${req.session.user.username}, you have already posted today.`
+ }
+ res.render('new.spy', data)
+ })
+})
+
app.get('/edit', requireLoggedIn, (req, res) => {
- getLatestPost( req.session.user.directory, (data, path) => {
- res.render('edit.spy', {data: data, path: path, title: 'Edit'})
+ return getLatestPost(req.session.user.directory, true, (dateString) => {
+ if (dateString) {
+ return getLatestPost( req.session.user.directory, false, (message, path) => {
+ res.render('edit.spy', {message: message, path: path, title: 'Edit'})
+ })
+ } else {
+ res.redirect('/new')
+ }
})
})
@@ -118,7 +131,7 @@ app.post('/publish', requireLoggedIn, (req, res) => {
app.post('/save', requireLoggedIn, (req, res) => {
saveFile(req.session.user.username, req.body.textarea, () => {
- res.redirect('/')
+ res.redirect('/new')
})
})
diff --git a/static/style.css b/static/style.css
index afa4dee..e0f4080 100644
--- a/static/style.css
+++ b/static/style.css
@@ -77,11 +77,34 @@ main {
text-decoration: none;
}
+.home-menu {
+ margin: auto;
+ padding: 0;
+ text-align: center;
+}
+
+.home-button {
+ background: none;
+ color: inherit;
+ border: none;
+ padding: 0;
+ font: 2em sans-serif;
+ cursor: pointer;
+ outline: inherit;
+ text-decoration: none;
+ display: inline-block;
+ margin-bottom: 1em;
+}
+
.disabled {
background-color: #999;
color: #000;
}
+section.disabled {
+ display: none;
+}
+
.password-reset {
width: 100%;
margin-bottom: 1em;
@@ -100,3 +123,9 @@ main {
.menu-help {
font-weight: bolder;
}
+
+.alert {
+ margin: auto;
+ color: red;
+ font-weight: bold;
+}
diff --git a/templates/edit.spy b/templates/edit.spy
index 7fb16de..dbf4466 100644
--- a/templates/edit.spy
+++ b/templates/edit.spy
@@ -1,13 +1,16 @@
<< partials/head >>
- << partials/header >>
+
diff --git a/templates/help.spy b/templates/help.spy
index 319ffee..22dc8f3 100644
--- a/templates/help.spy
+++ b/templates/help.spy
@@ -1,6 +1,9 @@
<< partials/head >>
- << partials/header >>
+
Help
Soyuz is a web app for writing Gemini posts.
diff --git a/templates/index.spy b/templates/index.spy
index e6c98fb..ae2f0c7 100644
--- a/templates/index.spy
+++ b/templates/index.spy
@@ -1,17 +1,10 @@
<< partials/head >>
- << partials/header >>
-
-
-
+
diff --git a/templates/new.spy b/templates/new.spy
new file mode 100644
index 0000000..9622ddc
--- /dev/null
+++ b/templates/new.spy
@@ -0,0 +1,21 @@
+<< partials/head >>
+
+
+
+
+
+
+
+
+
diff --git a/templates/partials/header.spy b/templates/partials/header.spy
deleted file mode 100644
index e23cff2..0000000
--- a/templates/partials/header.spy
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/templates/published.spy b/templates/published.spy
index ccddebc..c2c4699 100644
--- a/templates/published.spy
+++ b/templates/published.spy
@@ -1,7 +1,12 @@
<< partials/head >>
- << partials/header >>
+
{{ title }}
Hooray 🎉
diff --git a/templates/settings.spy b/templates/settings.spy
index 15e5137..885c175 100644
--- a/templates/settings.spy
+++ b/templates/settings.spy
@@ -1,6 +1,9 @@
<< partials/head >>
- << partials/header >>
+