From 5a5b666794b688881eb1e1635bf9f2ceb3cc4346 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 19 Dec 2020 22:35:50 -0600 Subject: Add title to posts --- src/css/styles.css | 4 ++++ src/html/admin.html | 3 +++ src/index.js | 3 +++ src/server.js | 40 ++-------------------------------------- src/templates/feed.html | 3 +++ 5 files changed, 15 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/css/styles.css b/src/css/styles.css index f406104..ab634ec 100644 --- a/src/css/styles.css +++ b/src/css/styles.css @@ -30,6 +30,10 @@ h1 { margin-left: 20px; } +.card-title { + margin-left: 0; +} + @keyframes zoom-left { 0% {left: 100%; } 100% {left: 0;} diff --git a/src/html/admin.html b/src/html/admin.html index 3eaa60a..29e4b87 100644 --- a/src/html/admin.html +++ b/src/html/admin.html @@ -41,6 +41,9 @@

Create Post

+
+ +
diff --git a/src/index.js b/src/index.js index 4b9a3c6..a94f8d0 100644 --- a/src/index.js +++ b/src/index.js @@ -53,6 +53,9 @@ function setUpModels(){ type: { type: Sequelize.STRING, allowNull: false, + }, + title: { + type: Sequelize.STRING, },}), "pictures": database.define('pictures', { source: { type: Sequelize.TEXT, allowNull: false}, diff --git a/src/server.js b/src/server.js index 2198923..81b7b0e 100644 --- a/src/server.js +++ b/src/server.js @@ -50,43 +50,6 @@ function hashWithSalt(password, salt){ return hash.digest("base64"); }; -function constructFeed(posts){ - var html = [] - html.push(`
`) - posts.forEach(post => { - html.push(`
-

${post.description}

-
`) - post.images.forEach(image => { - html.push(` - - `) - }) - html.push(`
-

- ${post.createdAt.toString().substring(0,10)}`) - post.tags.forEach(tag => { - html.push(` - ${tag} - `) - }) - html.push(`

-
`) - }) - html.push(`
`) - return html.join(""); -} - -async function constructFeedFromType(models, postType){ - var posts = await models.posts.findAll({ - where: { type: postType }, order: [['createdAt', 'DESC']] - }); - posts = posts.map(x => x.get({ plain: true })); - await addImagesAndTagsToPosts(models, posts) - - return constructFeed(posts) -} - async function formatPostsforSingle(models, postType, postId){ var posts = await models.posts.findAll({ where: { @@ -110,6 +73,7 @@ async function formatPostsForType(models, postType){ await addImagesAndTagsToPosts(models, posts) posts.forEach(post => { post.createdAt = post.createdAt.toString().substring(0, 10) + post.showTitle = post.type != "bread" }) return posts; } @@ -384,7 +348,7 @@ function setUpRoutes(models, jwtFunctions, database, templates) { posts = posts.map(x => x.get({ plain: true })); posts.forEach(post =>{ feed.item({ - title: post.createdAt.toString().substring(0, post.createdAt.toString().indexOf(" GMT")), + title: post.title, description: post.description, date: post.createdAt, url: `https://marks.kitchen/post/${post.type}/${post.id}`, diff --git a/src/templates/feed.html b/src/templates/feed.html index 2158f3e..d7494a2 100644 --- a/src/templates/feed.html +++ b/src/templates/feed.html @@ -1,6 +1,9 @@
{{#each posts}}
+ {{#if this.showTitle}} +

{{this.title}}

+ {{/if}}

{{{this.description}}}

{{#each this.images}} -- cgit v1.2.3