diff options
| -rw-r--r-- | .env | 6 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .sample-env | 2 | ||||
| -rw-r--r-- | lib/bucky.js | 6 | ||||
| -rw-r--r-- | lib/db/index.js | 34 | ||||
| -rw-r--r-- | lib/router.js | 2 | ||||
| -rw-r--r-- | public/assets/css/bucky.css | 68 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/index.js | 17 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/index.js | 2 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 26 | ||||
| -rw-r--r-- | public/assets/js/util/format.js | 9 | ||||
| -rw-r--r-- | public/assets/js/vendor/view/view.js | 1 | ||||
| -rw-r--r-- | views/pages/details.ejs | 9 | ||||
| -rw-r--r-- | views/pages/message.ejs | 2 | ||||
| -rw-r--r-- | views/partials/comments.ejs | 4 | ||||
| -rw-r--r-- | views/partials/files.ejs | 2 | ||||
| -rw-r--r-- | views/partials/gallery.ejs | 2 | ||||
| -rw-r--r-- | views/partials/header.ejs | 2 | ||||
| -rw-r--r-- | views/partials/hootbox.ejs | 2 | ||||
| -rw-r--r-- | views/partials/threads.ejs | 18 |
20 files changed, 160 insertions, 56 deletions
@@ -1,6 +0,0 @@ -DB_HOST=localhost -DB_NAME=bucky -DB_USER=carbon -DB_PASS=argon -HOST_NAME=5.k - @@ -9,4 +9,4 @@ node_modules/ dist *.sql .env - +public/data diff --git a/.sample-env b/.sample-env index 7c447f4..9a57f81 100644 --- a/.sample-env +++ b/.sample-env @@ -1,5 +1,5 @@ DB_HOST=localhost -DB_NAME=bucky +DB_NAME=bucky3 DB_USER=carbon DB_PASS=argon HOST_NAME=5.k diff --git a/lib/bucky.js b/lib/bucky.js index bfc4b6f..70910ef 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -21,7 +21,9 @@ var bucky = module.exports = { lookup[c.thread] = c }) res.threads.forEach(function(thread){ - thread.set("comment_count", lookup[thread.id].count) + if (lookup[thread.id]) { + thread.set("comment_count", lookup[thread.id].count) + } }) next() }) @@ -58,7 +60,7 @@ var bucky = module.exports = { }) }, ensureHootbox: function (req, res, next){ - db.getCommentsForThread(1, 9, 0, "desc").then(function(hootbox){ + db.getCommentsForThread(1, 15, 0, "desc").then(function(hootbox){ res.hootbox = hootbox next() }) diff --git a/lib/db/index.js b/lib/db/index.js index b6fa235..6906b27 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -58,7 +58,6 @@ db.getLastlog = function(limit){ return knex.column('username').column('lastseen').select().from('users').orderBy('lastseen', 'desc').limit(limit || 10) } - /* THREADS */ db.getLatestThreads = function () { @@ -74,7 +73,12 @@ db.getThreadsForKeyword = function (keyword) { db.getThread = function (id) { return Thread.query("where", "id", "=", id).fetch() } - +db.createThread = function(data){ +} +db.updateThread = function(data){ +} +db.removeThread = function(id){ +} /* FILES */ @@ -87,7 +91,10 @@ db.getFileCounts = function(ids){ db.getFileSizes = function(ids){ return knex.column('thread').sum('size as size').select().from('files').where('thread', 'in', ids).groupBy('thread') } - +db.createFile = function(data){ +} +db.removeFile = function(id){ +} /* COMMENTS */ @@ -111,6 +118,12 @@ db.getCommentsForThread = function (id, limit, offset, order){ db.getCommentCounts = function(ids){ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') } +db.createComment = function(data){ +} +db.updateComment = function(data){ +} +db.removeComment = function(id){ +} /* KEYWORDS */ @@ -121,6 +134,12 @@ db.getKeywords = function (keywords){ db.getKeyword = function (keyword) { return Keyword.query("where", "keyword", "=", keyword).fetch() } +db.createKeyword = function(data){ +} +db.updateKeyword = function(data){ +} +db.removeKeyword = function(id){ +} /* MAILBOXES */ @@ -131,7 +150,8 @@ db.getMailboxes = function(username){ db.getMailboxCounts = function(boxes){ return knex.column('mbox').count('* as count').select().from('messages').where('mbox', 'in', boxes).groupBy('mbox') } - +db.createMailbox = function(data){ +} /* MESSAGES */ @@ -154,3 +174,9 @@ db.getMessage = function (id){ return message }) } +db.createMessage = function(data){ +} +db.updateMessage = function(data){ +} +db.removeMessage = function(id){ +} diff --git a/lib/router.js b/lib/router.js index 66aa1bf..4451a13 100644 --- a/lib/router.js +++ b/lib/router.js @@ -29,13 +29,13 @@ module.exports = function(app){ app.post("/api/login", auth.loggedInLocal) app.get("/api/index", + bucky.ensureLastlog, middleware.ensureAuthenticated, bucky.ensureLatestThreads, bucky.ensureCommentCountsForThreads, bucky.ensureFileCountsForThreads, bucky.ensureKeywordsForThreads, bucky.ensureHootbox, - bucky.ensureLastlog, function(req, res){ res.json({ threads: res.threads, diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css index 24ed78e..08d25d3 100644 --- a/public/assets/css/bucky.css +++ b/public/assets/css/bucky.css @@ -133,28 +133,45 @@ table, tr { #hoots tr:nth-child(odd) td:nth-child(2) { background-color: #f3f1f2; } #hoots tr:nth-child(even) td:nth-child(2) { background-color: #e3e8e3; } -#threads th { +#threads .keyword td { vertical-align: top; font-weight: normal; padding-right: 4px; line-height: 15px; + padding-top: 10px; } -#threads th b { +#threads .keyword:first-child td { + padding-top: 5px; +} +#threads .keyword td:first-child { + text-align: right; +} +#threads .keyword td b { font-weight: bold; font-size: 14px; } +#threads .keyword:first-child td:nth-child(2) { + border-top: 0; +} +#threads .keyword td:nth-child(2) { + border-top: 1px solid #b3b3b3; + border-bottom: 1px solid #b3b3b3; +} +#threads .row:last-child td:nth-child(2) { + border-bottom: 1px solid #b3b3b3; +} -.ledger td { +.ledger .row td { text-align: right; padding-left: 4px; padding-right: 4px; } -.ledger td:nth-child(1) a { +.ledger .row td:nth-child(1) a { margin-left: 10px; color: #444; text-decoration: none; } -.ledger td:nth-child(2) { +.ledger .row td:nth-child(2) { text-align: left; font-family: Georgia, serif; font-size: 120%; @@ -165,10 +182,10 @@ table, tr { max-width: 30vw; white-space: nowrap; } -.ledger tr:first-child td:nth-child(2) { +.ledger tr.row:first-child td:nth-child(2) { border-top: 1px solid #b6aeab; } -.ledger tr:last-child td:nth-child(2) { +.ledger tr.row:last-child td:nth-child(2) { border-bottom: 1px solid #b6aeab; } .ledger td:nth-child(2) a { @@ -178,10 +195,10 @@ table, tr { text-align: center; } -tr:nth-child(odd).row td { background-color: #e6f0f0; } -tr:nth-child(odd).row:hover td { background-color: #d8e0ec; color: #000000; } -tr:nth-child(even).row td { background-color: #e0e8e8; } -tr:nth-child(even).row:hover td { background-color: #d8e0ec; color: #000000; } +tr:nth-child(odd).file td { background-color: #e6f0f0; } +tr:nth-child(odd).file:hover td { background-color: #d8e0ec; color: #000000; } +tr:nth-child(even).file td { background-color: #e0e8e8; } +tr:nth-child(even).file:hover td { background-color: #d8e0ec; color: #000000; } tr:nth-child(odd) td.row { background-color: #e6f0f0; } tr:nth-child(odd) td.row:hover { background-color: #d8e0ec; color: #000000; } @@ -250,10 +267,6 @@ tr:nth-child(even) td.black:hover { background-color: #f8f8f8; color: #000000; .older { color: #5D6464; } .quiet { color: #787878; } -#details .left { - padding-right: 20px; - vertical-align: top; -} #details_rapper { width: 100%; text-align: center; @@ -261,6 +274,11 @@ tr:nth-child(even) td.black:hover { background-color: #f8f8f8; color: #000000; #details { display: inline-block; text-align: left; + width: 100%; +} +#details .left { + vertical-align: top; + max-width: 50%; } #details .right { max-width: 50vw; @@ -272,6 +290,13 @@ tr:nth-child(even) td.black:hover { background-color: #f8f8f8; color: #000000; border-bottom: 1px solid #ccc; border-left: 1px solid #ccc; border-right: 1px solid #ccc; + min-width: 400px; +} +#comments { + max-width: 450px; +} +#comments tr { + padding-right: 20px; } #comments tr .user { margin: 0; @@ -280,8 +305,14 @@ tr:nth-child(even) td.black:hover { background-color: #f8f8f8; color: #000000; font-size: 11px; vertical-align: top; } -#comments tr .user img { +#comments tr .user .avatar { border: 1px solid; + width: 40px; + height: 40px; + background-size: cover; + margin: 0 auto; + margin-bottom: 2px; + background-position: center center; } #comments tr:first-child .comment { border-top: 1px solid #ccc; @@ -337,6 +368,9 @@ tr:nth-child(odd) td.comment { background-color: #fcf8f8; } text-align: center; padding: 0 0 12px 0; } +#gallery .thumb { + max-width: 150px; +} #messages { width: 100%; @@ -376,7 +410,7 @@ tr:nth-child(odd) td.comment { background-color: #fcf8f8; } line-height: 15px; padding: 20px; } -@media (max-width: 1024px) { +@media (max-width: 700px) { #threads td:nth-child(3) small { display: none; } diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js index 554c475..6290738 100644 --- a/public/assets/js/lib/views/details/index.js +++ b/public/assets/js/lib/views/details/index.js @@ -6,11 +6,13 @@ var DetailsView = View.extend({ action: "/api/thread/", keywordAction: "/api/keyword/", + initialize: function(opt){ this.comments = new CommentsView ({ parent: this }) this.files = new FilesView ({ parent: this }) this.gallery = new GalleryView ({ parent: this }) this.threadbox = new ThreadBox ({ parent: this }) + this.metadataTemplate = $(".metadata_template").html() }, load: function(id){ @@ -19,7 +21,20 @@ var DetailsView = View.extend({ }, populate: function(data){ - $("h1").html(data.thread.title) + var thread = data.thread + $("h1").html(thread.title) + var datetime = verbose_date(thread.createdate, true) + var age = get_age(thread.lastmodified, true) + var t = this.metadataTemplate + .replace(/{{ username }}/g, thread.username) + .replace(/{{ date }}/g, datetime[0]) + .replace(/{{ time }}/g, datetime[1]) + .replace(/{{ active }}/g, age + " ago") + .replace(/{{ views }}/g, thread.viewed + " " + courtesy_s(thread.viewed, "view")) +console.log(t) + console.log(data.thread) +// name date time active views + $(".metadata").html(t) this.comments.load(data.comments) this.files.load(data.files) this.gallery.load(data.files) diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js index a1e8af5..d66ea1c 100644 --- a/public/assets/js/lib/views/index/index.js +++ b/public/assets/js/lib/views/index/index.js @@ -8,7 +8,7 @@ var IndexView = View.extend({ initialize: function(opt){ // opt.parent = parent this.hootbox = new HootBox ({ parent: this }) - this.threadbox = new ThreadBox ({ parent: this }) + this.threadbox = new ThreadBox ({ parent: this, latest: true }) this.lastlog = new LastLog ({ parent: this }) this.load() }, diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index 0475382..0c6a4be 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -12,10 +12,26 @@ var ThreadBox = View.extend({ load: function(data){ if (data.keyword) { - var $row = this.parseKeyword(data.keyword) - this.$el.append($row) + this.appendKeyword(data.keyword) + data.threads.forEach(this.appendThread.bind(this)) + } + else if (this.options.latest) { + data.threads.sort( (a,b) => { + return b.lastmodified - a.lastmodified + }).slice(0, 50).forEach(this.appendThread.bind(this)) + } + else { + var keywords = {} + data.threads.forEach((thread) => { + var keyword = thread.keyword || '__unsorted' + keywords[keyword] = keywords[keyword] || [] + keywords[keyword].push(thread) + }) + Object.keys(keywords).sort().forEach((keyword) => { + this.appendKeyword({ keyword }) + keywords[keyword].forEach(this.appendThread.bind(this)) + }) } - data.threads.forEach(this.appendThread.bind(this)) }, parse: function(thread){ @@ -65,4 +81,8 @@ var ThreadBox = View.extend({ this.$el.append($row) }, + appendKeyword: function(keyword){ + var $row = $( this.parseKeyword(keyword) ) + this.$el.append($row) + }, }) diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 501108a..889ab09 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -132,7 +132,7 @@ function hush_null (n, unit, no_bold) { } } -function courtesy_s (n, s) { return v == 1 ? "" : (s || "s") } +function courtesy_s (n, s) { return n == 1 ? "" : (s || "s") } var revision_letters = "z a b c d f g h j k l m n p q r s t v w x y".split(" ") function get_revision (thread) { @@ -207,10 +207,11 @@ function make_link(file){ } function make_thumb(file){ if (file.filename.indexOf("http") !== 0) { - return "//carbonpictures.com/bucky/data/" + file.thread + "/.thumb/t." + file.filename.toLowerCase() + return "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename } else { - var partz = file.filename.toLowerCase().split("/") - return partz.splice(partz.length-2, 0, ".thumb").join("/") + return "//carbonpictures.com/bucky/data/" + file.thread + "/" + file.filename + // var partz = file.filename.toLowerCase().split("/") + // return partz.splice(partz.length-2, 0, ".thumb").join("/") } }
\ No newline at end of file diff --git a/public/assets/js/vendor/view/view.js b/public/assets/js/vendor/view/view.js index 9a8ab5b..82e5117 100644 --- a/public/assets/js/vendor/view/view.js +++ b/public/assets/js/vendor/view/view.js @@ -4,6 +4,7 @@ var View = (function($, _){ this._id = _.uniqueId('view') this.type = "view" options || (options = {}); + this.options = options _.extend(this, _.pick(options, viewOptions)) this._ensureElement() this.initialize.apply(this, arguments) diff --git a/views/pages/details.ejs b/views/pages/details.ejs index 769db9d..b508560 100644 --- a/views/pages/details.ejs +++ b/views/pages/details.ejs @@ -3,6 +3,15 @@ <hr> <div id="details_rapper"> + <script type="text/html" class="metadata_template"> + Posted by {{ username }} + on {{ date }} {{ time }} + · + Last active {{ active }} + · + {{ views }} + </script> + <table id="details"> <tr> <td class="left"> diff --git a/views/pages/message.ejs b/views/pages/message.ejs index 333908d..bd71a0a 100644 --- a/views/pages/message.ejs +++ b/views/pages/message.ejs @@ -4,7 +4,7 @@ <div class="bluebox" id="message"> <script class="template" type="text/html"> - <a href="/profile/{{sender}}" class="av"><img src="//www.carbonpictures.com/bucky/data/profile/.thumb/al.{{sender}}.jpg"></a> + <a href="/profile/{{sender}}" class="av"><img src="/data/profile/.thumb/al.{{sender}}.jpg"></a> <span class="subject">{{subject}}</span> <span class="sender"> sent by diff --git a/views/partials/comments.ejs b/views/partials/comments.ejs index 97d4cea..30f471c 100644 --- a/views/partials/comments.ejs +++ b/views/partials/comments.ejs @@ -1,8 +1,8 @@ -<table id="comments" width="450"> +<table id="comments"> <script class="template" type="text/html"> <tr> <td class="user"> - <a href="/profile/{{username}}"><img src="//www.carbonpictures.com/bucky/data/profile/.thumb/al.{{username}}.jpg"></a><br> + <a href="/profile/{{username}}"><div class="avatar" style="background-image:url(/data/profile/{{username}}.jpg)"></div></a> <a href="/profile/{{username}}">{{username}}</a> </td> <td colspan="2" class="comment"> diff --git a/views/partials/files.ejs b/views/partials/files.ejs index d72dcdc..34d476a 100644 --- a/views/partials/files.ejs +++ b/views/partials/files.ejs @@ -1,7 +1,7 @@ <div id="audio"></div> <table id="files"> <script class="template" type="text/html"> - <tr class="row"> + <tr class="file"> <td> <a href="{{link}}" class="file">{{filename}}</a> </td> diff --git a/views/partials/gallery.ejs b/views/partials/gallery.ejs index 8fac271..7115d4d 100644 --- a/views/partials/gallery.ejs +++ b/views/partials/gallery.ejs @@ -1,7 +1,7 @@ <div id="gallery"> <script class="template" type="text/html"> <div> - <a href="{{link}}"><img src="{{thumb}}"></a> + <a href="{{link}}"><img class="thumb" src="{{thumb}}"></a> <br>(<a href="/profile/{{username}}">{{username}}</a>, {{age}}) </div> </script> diff --git a/views/partials/header.ejs b/views/partials/header.ejs index 6cd7b2e..f5b21dc 100644 --- a/views/partials/header.ejs +++ b/views/partials/header.ejs @@ -8,7 +8,7 @@ <body> <h1><%= title %></h1> - +<span class="metadata"></span> <hr> <% if (show_header) { %> diff --git a/views/partials/hootbox.ejs b/views/partials/hootbox.ejs index c65d264..3856f94 100644 --- a/views/partials/hootbox.ejs +++ b/views/partials/hootbox.ejs @@ -6,7 +6,7 @@ <table id="hoots"> <script class="template" type="text/html"> <tr> - <td style="background-image:url(//www.carbonpictures.com/bucky/data/profile/.thumb/am.{{username}}.jpg)"><a href="/profile/{{username}}"><div></div></a></td> + <td style="background-image:url(/data/profile/{{username}}.jpg)"><a href="/profile/{{username}}"><div></div></a></td> <td> {{comment}} </td> diff --git a/views/partials/threads.ejs b/views/partials/threads.ejs index b809be8..db54445 100644 --- a/views/partials/threads.ejs +++ b/views/partials/threads.ejs @@ -1,21 +1,22 @@ <table class="ledger" id="threads"> + <script class="keywordTemplate" type="text/html"> - <tr> - <th> + <tr class='keyword'> + <td> <b>{{keyword}}</b> · - </th> - <th> + </td> + <td> <a href="/post/{{keyword}}">post</a> - </th> + </td> </tr> </script> + <script class="template" type="text/html"> - <tr> + <tr class='row'> <td> - <a href="/profile/{{username}}">{{username}}</a> - {{privacy_dot}} + <a href="/profile/{{username}}">{{username}}</a> {{privacy_dot}} </td> <td class="{{color}}"> <a href="/details/{{id}}">{{title}}</a> @@ -38,4 +39,5 @@ </td> </tr> </script> + </table> |
