diff options
27 files changed, 255 insertions, 971 deletions
diff --git a/lib/bucky.js b/bucky/app/bucky.js index 70910ef..757592a 100644 --- a/lib/bucky.js +++ b/bucky/app/bucky.js @@ -1,5 +1,5 @@ -var db = require('./db') -var util = require('./util') +var db = require('../db') +var util = require('../util/util') var _ = require('lodash') var bucky = module.exports = { @@ -138,6 +138,26 @@ var bucky = module.exports = { }) }, + /* COMMENTS */ + + createComment: function (req, res, next){ + if (! req.body.comment || ! req.body.comment.length) { + res.json({ error: "no comment" }) + return + } + var data = { + thread: res.thread.get('id'), + parent_id: req.body.parent_id || -1, + username: req.user.get('username'), + date: util.now(), + comment: req.body.comment, + } + db.createComment(data).then(function(comment){ + res.comment = comment + next() + }) + }, + /* MAIL */ ensureMailboxes: function (req, res, next){ diff --git a/lib/index.js b/bucky/app/index.js index 5aef342..03c5593 100644 --- a/lib/index.js +++ b/bucky/app/index.js @@ -9,6 +9,7 @@ var csurf = require('csurf') var path = require('path') var multiparty = require('multiparty') var ejs = require('ejs') +var favicon = require('serve-favicon') var passport = require('passport') var sessionstore = require('sessionstore') var session = require('express-session') @@ -23,8 +24,10 @@ site.init = function(){ app = express() app.set('port', 5000) app.set('view engine', 'ejs') - app.set('views', path.join(__dirname, '../views')) - app.use(express.static(path.join(__dirname, '../public'))) + app.set('views', path.join(__dirname, '../../views')) + app.use(express.static(path.join(__dirname, '../../public'))) + + app.use(favicon(__dirname + '../../public/favicon.ico')) app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) app.use( multer({ dest:'./uploads/' }).single("file") ) diff --git a/lib/router.js b/bucky/app/router.js index c08037e..c3af565 100644 --- a/lib/router.js +++ b/bucky/app/router.js @@ -68,26 +68,13 @@ module.exports = function(app){ app.post("/api/thread/:id/comment", middleware.ensureAuthenticated, bucky.ensureThread, + // ensure thread privacy + bucky.createComment, function(req, res){ - if (!req.params.id) return res.sendStatus(500) - var comment = { - thread: req.params.id, - parent_id: req.body.parent_id || -1, - username: req.user.get('username'), - date: Math.round(+(new Date) / 1000), - comment: req.body.comment, - hidden: false, - } - db.createComment(comment).then(function(c){ - res.json(comment) + res.json({ + comment: res.comment }) }) - app.post("/api/thread/:id/file", - middleware.ensureAuthenticated, - bucky.ensureThread, - function(req, res){ - // add comments and files - }) app.delete("/api/thread/:id", middleware.ensureAuthenticated, function(req, res){ diff --git a/lib/db/bookshelf.js b/bucky/db/bookshelf.js index 69157cc..69157cc 100644 --- a/lib/db/bookshelf.js +++ b/bucky/db/bookshelf.js diff --git a/lib/fortune.js b/bucky/db/fortune.js index 7adba5a..7adba5a 100644 --- a/lib/fortune.js +++ b/bucky/db/fortune.js diff --git a/lib/db/index.js b/bucky/db/index.js index f376308..f376308 100644 --- a/lib/db/index.js +++ b/bucky/db/index.js diff --git a/lib/auth.js b/bucky/util/auth.js index 38901e4..436d5e6 100644 --- a/lib/auth.js +++ b/bucky/util/auth.js @@ -2,7 +2,7 @@ var passport = require('passport'), LocalStrategy = require('passport-local').Strategy, crypto = require('crypto'), - db = require('./db'); + db = require('../db'); var auth = module.exports = { diff --git a/lib/middleware.js b/bucky/util/middleware.js index a744c89..a744c89 100644 --- a/lib/middleware.js +++ b/bucky/util/middleware.js diff --git a/lib/util.js b/bucky/util/util.js index e67488b..d4b6b8a 100644 --- a/lib/util.js +++ b/bucky/util/util.js @@ -2,3 +2,5 @@ var util = module.exports = {} util.sanitizeName = function (s){ return (s || "").replace(new RegExp("[^-_a-zA-Z0-9]", 'g'), "") } util.sanitize = function (s){ return (s || "").replace(/<>&/g, "") } + +util.now = function(){ return Math.floor( (+ new Date()) / 1000 ) } @@ -1,2 +1,2 @@ -var app = require('./lib') +var app = require('./bucky/app/index') app.init() diff --git a/lib/search/index.js b/lib/search/index.js index 8d209e6..27f436f 100644 --- a/lib/search/index.js +++ b/lib/search/index.js @@ -35,8 +35,16 @@ var STOPWORDS = new Set( ); function find_term(term) { - bdb.get(term) - + var matches = bdb.get(term).split(",").map((s) => { + var partz = s.split(" ") + var match = { + thread: s[0], + comment: s[1], + file: s[2], + strength: s[3], + } + }) + return matches } function search (query, start, limit) { diff --git a/lib/search/snippet.js b/lib/search/snippet.js new file mode 100644 index 0000000..de71911 --- /dev/null +++ b/lib/search/snippet.js @@ -0,0 +1,103 @@ +var util = require('../util/util') + +function bold_terms (s, terms) { + +} +sub bold_terms + { + my ($self, $string, $terms) = @_; + $string = $self->strip_html($string); + foreach my $term (@$terms) + { + $string =~ s/\b($term)\b/<b>$1<\/b>/gi; + } + return $string; + } +sub bold_snippet + { + my ($self, $string, $terms) = @_; + my $snippet = $self->snippet($string, $terms); + return $self->bold_terms($snippet, $terms); + } +sub snippet + { + my ($self, $string, $terms) = @_; + + # clean up the string we got + $string = $self->strip_html($string); + + # create a regex out of the search terms + my $term_re = join "|", @$terms; + + # take the string to be snippetized and split it into words + my @words = split /\s+/, $string; + + # deduper for matching @words indexes, so we don't add a word twice + my $index_matches = {}; + + # words in the eventual snippet + my @words_matched; + + # the snippet itself + my $snippet = ''; + + # counter for aggregating context after a match + my $aggr = 0; + + # amount of context to show, in number of words surrounding a match + my $pad = 4; + + # loop over each of the words in the string + for (my $i = 0; $i < scalar @words; $i++) + { + # does this word contain a match? + if ($words[$i] =~ /\b($term_re)\b/i && ! $self->is_stopword($1)) + { + # if we aren't already aggregating, add an ellipsis + if (! $aggr) + { + push @words_matched, "..."; + } + # look backward $pad words + for (my $j = -$pad; $j < 1; $j++) + { + # create a new index from the offset + my $idx = $i + $j; + + # is this a valid index? has it already been encountered? + next if $idx < 0; + next if $idx > scalar @words; + next if exists $index_matches->{$i+$j}; + + # checks out, save this word + push @words_matched, $words[$i+$j]; + + # note the matching index in our deduper + $index_matches->{$i+$j} ++; + } + # enter aggregate mode -- add the next $pad words + $aggr = $pad; + } + # have we been told to aggregate? + elsif ($aggr) + { + # save this word + push @words_matched, $words[$i]; + + # add index to the deduper + $index_matches->{$i} ++; + + # one less word to aggregate + $aggr--; + } + # keep snippets to a modest length + last if scalar @words_matched > 30; + } + # add a trailing ellipsis + push @words_matched, "..."; + + # create the snippet from the saved context words + $snippet = join " ", @words_matched; + + return $snippet; + }
\ No newline at end of file diff --git a/package.json b/package.json index 3bdbf13..993f57e 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "mysql2": "^0.15.8", "passport": "^0.3.0", "passport-local": "^1.0.0", + "serve-favicon": "^2.3.0", "sessionstore": "^1.2.5", "skipper": "^0.5.5" } diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css index 98cc9f8..c791ca1 100644 --- a/public/assets/css/bucky.css +++ b/public/assets/css/bucky.css @@ -17,7 +17,7 @@ label { text-align: right; padding-right: 5px; } -button { +button, input[type=submit] { font-size: 10px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif; font-weight: bold; @@ -28,7 +28,8 @@ button { background-color: #c8d0dc; text-transform: uppercase; } -.desktop button:hover { +.desktop button:hover, +.desktop input[type=submit] { color: #040a0a; background-color: #d8ece0; } @@ -82,7 +83,8 @@ table, tr { width: -webkit-calc(100% - 310px); width: calc(100% - 310px); } -.threads { + +#content .ledger { width: 100%; } @@ -333,6 +335,23 @@ tr:nth-child(even) td.black:hover { background-color: #f8f8f8; color: #000000; tr:nth-child(even) td.comment { background-color: #f3f1f2; } tr:nth-child(odd) td.comment { background-color: #fcf8f8; } +#comment_form form { + width: 530px; + margin-top: 5px; + margin-left: 50px; + padding-right: 10px; +} +#comment_form textarea { + width: 100%; + height: 240px; + font-family: 'Trebuchet MS', sans-serif; + padding: 5px; + font-size: 15px; +} +#comment_form input[type=submit] { + float: right; +} + #files, #files tr { margin: 0; padding: 0; border-spacing: 0; @@ -378,6 +397,25 @@ tr:nth-child(odd) td.comment { background-color: #fcf8f8; } #messages { width: 100%; } +#messages tr td:nth-child(1) { + text-align: right; + padding-right: 3px; +} +#messages tr td:nth-child(2) { + padding: 5px; + border-left: 1px solid #ccc; + border-right: 1px solid #ccc; +} +#messages tr td:nth-child(3) { + text-align: center; + padding-left: 3px; +} +#messages tr:first-child td:nth-child(2) { + border-top: 1px solid #ccc; +} +#messages tr:last-child td:nth-child(2) { + border-bottom: 1px solid #ccc; +} #boxes table { width: 200px; font-size: 13px; diff --git a/public/assets/css/css/lost.css b/public/assets/css/css/lost.css deleted file mode 100644 index 699a7a9..0000000 --- a/public/assets/css/css/lost.css +++ /dev/null @@ -1,14 +0,0 @@ -body { background-color: #EFEFEF; } -body,div,.wl { font-family: "courier new",monospace; font-size: small; white-space: pre;} - -.h { background-color: yellow; } -.s { background-color: #DFDFDF; } - -.m { color: darkgreen; } /* mode */ -.j { color: darkgreen; } /* join */ -.p { color: darkgreen; } /* part */ -.q { color: darkblue; } /* quit */ -.k { color: darkblue; } /* kick */ -.t { color: darkblue; } /* topic */ -.a { color: darkred; } /* action */ -.n { color: darkred; } /* nick */ diff --git a/public/assets/css/css/poetaster.css b/public/assets/css/css/poetaster.css deleted file mode 100644 index ce0efc8..0000000 --- a/public/assets/css/css/poetaster.css +++ /dev/null @@ -1,25 +0,0 @@ -* - { - margin: 0; - padding: 0; - } -body - { - } -textarea - { - width: 300px; - height: 100px; - } -pre - { - white-space: pre; - font-family: georgia, serif; - font-size: 16px; - } -#container - { - width: 400px; - margin: 0 auto; - } - diff --git a/public/assets/css/css/style.css b/public/assets/css/css/style.css deleted file mode 100755 index 2d38361..0000000 --- a/public/assets/css/css/style.css +++ /dev/null @@ -1,137 +0,0 @@ -table - { - width: 100%; - border-collapse: collapse; - background-color: white; - color: black; - font: 10pt verdana, arial; - margin-bottom: 25%; /* %, px, em, ex ? */ - } - -tr.subhead - { - background-color: #cccccc; - } - -th - { - padding: 0 3%; - } - -th.alt - { - background-color: black; - color: white; - padding: 3% 3% 2%; - } - -td - { - padding: 0 3%; - } - -tr.alt - { - background-color: #eeeeee; - } - -h1 - { - font: 24pt verdana, arial; - margin: 0; - } - -h2 - { - font: 18pt verdana, arial; - margin: 0; - } - -h3 - { - font: 12pt verdana, arial; - margin: 0; - } - -th a - { - color: #00008b; - font: 8pt verdana, arial; - } - -a - { - color: #00008b; - text-decoration: none; - } - -a:hover - { - color: #00008b; - text-decoration: underline; - } - -div.outer - { - width: 90%; - margin: 15%; - } - -table.viewmenu td - { - background-color: #006699; - color: white; - padding: 0 5%; - } - -table.viewmenu td.end - { - padding: 0; - } - -table.viewmenu a - { - color: white; - font: 8pt verdana, arial; - } - -table.viewmenu a:hover - { - color: white; - font: 8pt verdana, arial; - } - -a.tinylink - { - color: #00008b; - font: 8pt verdana, arial; - text-decoration: underline; - } - -a.link - { - color: #00008b; - text-decoration: underline; - } - -div.buffer - { - padding-top: 7%; - padding-bottom: 17%; - } - -.small - { - font: 8pt verdana, arial; - } - -table td - { - padding-right: 20%; - } - -table td.nopad - { - padding-right: 5%; - } - diff --git a/public/assets/css/css/tabs.css b/public/assets/css/css/tabs.css deleted file mode 100755 index 3b7250e..0000000 --- a/public/assets/css/css/tabs.css +++ /dev/null @@ -1,98 +0,0 @@ -#screenTabs { -float:left; -width: 100%; -min-height: 1px; -height: 1px; -background:#ffffff url("../img/icons/tabs/bg.gif") repeat-x bottom; -} - -td > #screenTabs { -height: auto; -} - -#tabs { -float:left; -width:620px; -line-height:normal; -white-space: nowrap; -background:#ffffff url("../img/icons/tabs/bg.gif") repeat-x bottom; -} - -#tabs ul { -margin:0; -padding: 0px 10px 10px 10px; -list-style:none; -} - -#tabs a { -display: block; -background:url("../img/icons/tabs/right.gif") no-repeat right top; -padding:5px 9px 4px 4px; -vertical-align: baseline; -text-decoration: none; -color: #000000; -width:.1em; -} - -#tabs > ul a { -width: auto; -} - -#tabs a:hover, -#tabs a:visited, -#tabs a:active { -text-decoration: none; -color: #000000; -} - -#tabs li { -float:left; -background:url("../img/icons/tabs/left.gif") no-repeat left top; -margin:0; -padding:0 0 0 2px; -border-bottom: solid 1px #776655; -} - -#tabs li#current { -border-width: 0; -} - -#tabs #current { -background-image:url("../img/icons/tabs/left_on.gif"); -margin-left: -3px; -} -#tabs #current a { -background-image:url("../img/icons/tabs/right_on.gif"); -padding:3px 9px 7px 6px; -vertical-align: baseline; -} - -#tabs .last a { -background-image:url("../img/icons/tabs/right_last.gif"); -} - -#tabs .first { -background-image:url("../img/icons/tabs/left_first.gif"); -} - -#tabs .first#current { -margin-left: 0; -} - -#tabs li:hover { -background-position: 0% -150px; -cursor: pointer; -} - -#tabs li:hover a { -background-position: 100% -150px; -} - -#tabs li.first:hover { -background-position: top left; -} - -#tabs a:hover { -background-position: 100% -150px; -} - diff --git a/public/assets/css/css/winxp.blue.css b/public/assets/css/css/winxp.blue.css deleted file mode 100755 index 476e415..0000000 --- a/public/assets/css/css/winxp.blue.css +++ /dev/null @@ -1,650 +0,0 @@ -html - { - height: 100%; - min-height: 100%; - border-width: 0px; - } - -body - { - height: 100%; - min-height: 100%; - margin: 0px; - padding: 0px; - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - font-weight: normal; - background-color: #F9F8F8; - color: #000000; - } - -p, div, span { - font-size: 11px; -} - -.screenLayout { - position: relative; - min-height: 100%; - margin-bottom: 0; -} -* html .screenLayout { - height: 100%; -} - -.headerContainer - { - background-image: url('../img/common/top_bg.jpg'); - background-repeat: repeat-x; - background-position: left bottom; - background-color: #FEFEFE; - margin: 0px; - } - -.pageHeader - { - background-image: url('../img/common/top_body_bg.jpg'); - background-position: top right; - background-repeat: no-repeat; - text-align: left; - margin: 0px; - height: 50px; - } - -.pageHeader img - { - margin-left: 0px; - margin-top: 0px; - } - -.footerContainer - { - position: absolute; -/* visibility:hidden; */ - bottom: 0px; - height: 40px; - width: 100%; - border-top: solid 1px #6E89DD; - background-color: #8EA5EC; - margin-bottom: 0; - } - -.contentLayout - { - text-align: center; - padding-bottom: 120px; - } - -.contentContainer - { - width: 620px; - text-align: left; - margin-left: auto; - margin-right: auto; - /* - border-left: solid 1px #dddddd; - border-right: solid 1px #dddddd; - */ - } - -.pageContent - { - margin-top: 49px; - } - -.mainPageBanner - { - background-color: #ffffff; - background-image: url('../img/common/banner.gif'); - background-repeat: no-repeat; - border: solid 2px #A6BDDA; - padding: 20px 20px 10px 215px; - margin-bottom: 10px; -} - -.mainPageBanner p, -.mainPageBanner li - { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 12px; -} - -.mainPageBanner li - { - margin-bottom: 3px; -} - -.mainPageBanner ul - { - margin: 5px 0 10px 22px; - padding: 0; -} - -.mainPageBanner .welcomeText - { - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - color: #4A78B3; - font-size: 18px; - font-weight: bold; - margin-top: 0; - border-bottom: 1px solid #cccccc; - } - -.mainPageBanner hr { - height: 0; - border: 0; - border-bottom: 1px solid #cccccc; -} - -p.descriptionText - { - color: #555555; - font-weight: bold; - } - -.domainName - { - color: #000000; - } - -.pageContent p - { - margin: 0px; - margin-top: 10px; - padding: 5px; - } - -.pageContent li - { - padding: 2px; - } - -.formContainer - { - padding: 5px; - } - -form - { - margin: 0px; - padding: 0px; - } - -.buttonsContainer - { - margin-top: 10px; - text-align: right; - } - -.buttonsContainer .commonButton span - { - display: none; - } - -.buttonsContainer .commonButton button - { - width: 91px; - height: 21px; - text-align: center; - } - -.buttonsContainer .commonButton button - { - white-space: nowrap; - } - -.buttonsContainer .commonButton - { - margin-left: 14px; - } - -.buttonsContainer .commonButton span - { - background-position: 0 1px; - background-repeat: no-repeat; - background-color: transparent; - padding-left: 20px; - text-decoration: underline; - cursor: pointer; - padding-top: 1px; - padding-bottom: 4px; - } - -.commonButton - { - display: inline; - } - -.commonButton button - { - background-image: url('../img/glyph/btn_bg.gif'); - border: 0 solid white; - background-repeat: no-repeat; - } - -.commonButton button[disabled] - { - background-image: url('../img/glyph/btn_bg-disabled.gif'); - color: #999999; - } - -.commonButton button, -.commonButton - { - font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - color: #000000; - background-color: transparent; - } - -#bid-ok button - { - background-image: url('../img/glyph/btn_ok_bg.gif'); - padding-left: 8px; - } - -.formFields td.name - { - font-size: 11px; - vertical-align: top; - padding-left: 0; - padding-right: 10px; - padding-bottom: 10px; - width: 200px; - } - -.name - { - font-weight: bold; - color: #555555; - } - -legend - { - color: #0046D5; - margin-bottom: 5px; - margin-left: 0px; - padding-right: 3px; - vertical-align: middle; - padding-bottom: 3px; - } - -.testRelults - { - height: 26px; - margin-top: 5px; - margin-bottom: 10px; - border: solid 1px #999999; - padding: 5px; - padding-left: 26px; - background-repeat: no-repeat; - background-position: 5px 50%; - vertical-align: middle; - line-height: 26px; - } - -.testRelults#testSuccessful - { - background-color: #eeffee; - background-image: url('../img/icons/success.gif'); - } - -.testRelults#testFailed - { - background-color: #ffeeee; - background-image: url('../img/icons/fail.gif'); - } - -.testResult - { - vertical-align: middle; - font-weight: bold; - } - -.pageNavigation - { - padding: 5px; - background-color: #eeeeee; - } - -.pageNavigation ul - { - list-style: none; - padding: 0px; - margin: 0px; - } - -.pageNavigation li - { - display: inline; - padding: 5px; - padding-right: 0px; - white-space: nowrap; - } - -.pageNavigation a, -.pageNavigation a:link, -.pageNavigation a:visited, -.pageNavigation a:active, -.pageNavigation a:hover - { - color: #000000; - text-decoration: none; - font-weight: bold; - padding-left: 5px; - } - -.pageNavigation a:hover - { - color: #666666; - text-decoration: underline; - } - -.pathBar - { - color: #444444; - padding: 5px; - padding-top: 15px; - } - -.pathBar a:link, -.pathBar a:visited - { - color: #444444; - } - -.screenTitle - { - font-size: 18px; - font-family: "Franklin Gothic Medium", Verdana, Geneva, Arial, Helvetica, sans-serif; - color: #000000; - padding: 5px; - } - -.tabContent - { - border-left: solid 1px #999999; - border-right: solid 1px #999999; - border-bottom: solid 1px #999999; - padding: 5px; - background-color: #f9f9f9; - margin-top: 10px; - } - -.poweredBy - { - float: right; - padding: 5px; - padding-left: 0px; - } - -a img - { - border-width: 0px; - } - -.footDescription - { - float: left; - padding: 5px; - color: #2A3D9E; - height: 30px; - line-height: 30px; - vertical-align: middle; - } - -a, -a:link, -a:visited, -a:active, -a:hover - { - text-decoration: underline; - color: #324290; - } - -a:hover - { - color: #6F85F0; - } - -.iconsArea - { - padding-top: 20px; - white-space: normal; - } - -.iconsArea a, -.iconsArea a:link, -.iconsArea a:visited, -.iconsArea a:hover - { - color: #000000; - text-decoration: none; - white-space: nowrap; - } - -.icon - { - margin: 0 20px 5px 0; - display: -moz-inline-box; - display: inline-block; - width: 70px; - height: 15px; - background-image: url('../img/common/1x1.gif'); - background-repeat: no-repeat; - background-position: 50% 0%; - text-align: center; - padding-top: 35px; - cursor: pointer; - } -.icon span { - display: block; - width: 70px; - text-align: center; -} - -#asp - { - background-image: url('../img/glyph/btn_asp_bg.gif'); - } - -#aspnet - { - background-image: url('../img/glyph/btn_aspdotnet_bg.gif'); - } - -#coldfusion - { - background-image: url('../img/glyph/btn_coldfusion_bg.gif'); - } - -#perl - { - background-image: url('../img/glyph/btn_perl_bg.gif'); - } - -#php - { - background-image: url('../img/glyph/btn_php_bg.gif'); - } - -#python - { - background-image: url('../img/glyph/btn_python_bg.gif'); - } - -#ssi { - background-image: url('../img/glyph/btn_ssi_bg.gif'); -} - -#fcgi { - background-image: url('../img/glyph/btn_fast_cgi_bg.gif'); -} - -#miva { - background-image: url('../img/glyph/btn_miva_bg.gif'); -} - -.footDescription a:hover - { - color: #000066; - } -/* NewsFeeds Add */ -.dLayout { -table-layout: fixed; -border-collapse: collapse; -} - -.dColumn { -width: 50%; -vertical-align: top; -padding: 0; -} - -.dColumn.expanded { -width: 100% !important; -} - -.dBox { -margin: 10px 0 0 10px; -border-bottom: solid 1px #6f8add; -} -.first .dBox { -margin-left: 0; -} -.dBoxHeaderLayout { -height: 21px; -padding-left: 3px; -background: transparent url('../img/glyph/dBox-header-left.gif') no-repeat top left; -} -.dBoxHeaderArea { -height: 21px; -line-height: 21px; -vertical-align: middle; -overflow: hidden; -background: transparent url('../img/glyph/dBox-header-right.gif') no-repeat top right; -} -.dBoxFooterArea, -.dBoxHeaderArea { -padding: 0 5px; -white-space: nowrap; -} -.dBoxHeaderArea { -font-family: Tahoma, Arial, Helvetica, sans-serif; -font-size: 11px; -color: #fff; -font-weight: bold; -} -.dBoxHeaderArea .misc { -} -.dBoxFooterLayout { -height: 27px; -overflow: hidden; -border-left: solid 1px #6f8add; -border-right: solid 1px #6f8add; -} -.dBoxContent { -border-left: solid 1px #6f8add; -border-right: solid 1px #6f8add; -padding: 10px; -color: #000; -background-color: #ffffff; -} -.dBoxFooterArea { -background: transparent url('../img/glyph/dBox-footer-bg.gif') repeat-x; -height: 27px; -overflow: hidden; -text-align: right; -padding-right: 10px; -} -.wrapper { -clear: both; -height: 0; -overflow: hidden; -} -#refreshList { -display: -moz-inline-box; -display: inline-block; -padding-left: 20px; -background-image: url('../img/glyph/btn_refresh-list_bg.gif'); -background-repeat: no-repeat; -height: 16px; -margin-top: 5px; -} -.NFtitle { -font-weight: bold; -display: block; -} -.NFitem { -display: block; -margin-bottom: 5px; -} -.NFsource { -margin-right: 5px; -} -.NFstatus { -margin-right: 5px; -font-weight: bold; -} -.NFtime { -color: #333; -} -#testPages p { -margin: 0; -padding: 0; -} - - -/* New Top begin */ - -#topTxtBlock { - text-align: right; - margin-right: 30px; - white-space: nowrap; - height: 50px; -} - -#topCopyright { - text-align: right; - display: -moz-inline-box; - display: inline-block; - margin-right: 9px; - margin-top: 11px; -} - -#topTxtBanner { - display: -moz-inline-box; - display: inline-block; - border-left: 1px solid #dce7ff; - background-image: url('../img/common/vz_top.gif'); - background-position: 9px 3px; - background-repeat: no-repeat; - padding-left: 36px; - text-align: left; - -} - -#topCopyright a:link, -#topCopyright a:visited { - display: block; - text-decoration: none; - font-size: 11px; - color: #d6e0ff; - white-space: nowrap; -} - -#topTxtBanner a:link, -#topTxtBanner a:visited { - display: block; - text-decoration: none; - font-size: 11px; - color: #ffffff; - white-space: nowrap; -} - -.topLogo { -float: left; -} - - -/* New Top end */ diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js new file mode 100644 index 0000000..30671f2 --- /dev/null +++ b/public/assets/js/lib/views/details/commentform.js @@ -0,0 +1,33 @@ +var CommentForm = FormView.extend({ + + el: "#comment_form", + + events: { + }, + + action: "/api/thread/1/comment", + + initialize: function(){ + this.__super__.initialize.call(this) + this.template = this.$(".template").html() + this.$comment = this.$("[name=comment]") + }, + + load: function(thread){ + this.action = "/api/thread/" + thread.id + "/comment" + }, + + validate: function(){ + var errors = [] + var comment = $("[name=comment]").val() + if (! comment || ! comment.length) { + errors.push("Please enter a comment.") + } + return errors.length ? errors : null + }, + + success: function(comment){ + this.prependComment(comment) + this.$("[name=comment]").val("") + } +})
\ No newline at end of file diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js index 7757bae..cd8045a 100644 --- a/public/assets/js/lib/views/details/index.js +++ b/public/assets/js/lib/views/details/index.js @@ -11,6 +11,7 @@ var DetailsView = View.extend({ this.comments = new CommentsView ({ parent: this }) this.files = new FilesView ({ parent: this }) this.gallery = new GalleryView ({ parent: this }) + this.form = new CommentForm ({ parent: this }) this.threadbox = new ThreadBox ({ parent: this }) this.metadataTemplate = $(".metadata_template").html() }, @@ -31,10 +32,8 @@ var DetailsView = View.extend({ .replace(/{{ time }}/g, datetime[1]) .replace(/{{ active }}/g, age + " ago") .replace(/{{ views }}/g, thread.viewed + " view" + courtesy_s(thread.viewed)) -console.log(t) - console.log(data.thread) -// name date time active views $(".metadata").html(t) + this.form.load(data.thread) this.comments.load(data.comments) this.files.load(data.files) this.gallery.load(data.files) diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js index f93a689..cdd3eb0 100644 --- a/public/assets/js/lib/views/index/hootbox.js +++ b/public/assets/js/lib/views/index/hootbox.js @@ -5,21 +5,13 @@ var HootBox = FormView.extend({ events: { }, - validate: function(){ - var errors = [] - var comment = $("[name=comment]").val() - if (! comment || ! comment.length) { - errors.push("Please enter a comment.") - } - return errors.length ? errors : null - }, - action: "/api/thread/1/comment", initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() this.$hoots = this.$("#hoots") + this.$comment = this.$("[name=comment]") }, load: function(comments){ @@ -41,7 +33,16 @@ var HootBox = FormView.extend({ var $el = $( this.parse(comment) ) this.$hoots.append($el) }, - + + validate: function(){ + var errors = [] + var comment = $("[name=comment]").val() + if (! comment || ! comment.length) { + errors.push("Please enter a comment.") + } + return errors.length ? errors : null + }, + success: function(comment){ this.prependComment(comment) this.$("[name=comment]").val("") diff --git a/public/assets/js/vendor/view/formview.js b/public/assets/js/vendor/view/formview.js index 384e470..2c54d3e 100644 --- a/public/assets/js/vendor/view/formview.js +++ b/public/assets/js/vendor/view/formview.js @@ -80,7 +80,7 @@ var FormView = View.extend({ var action = typeof this.action == "function" ? this.action() : this.action if (! action) return - + var request = $.ajax({ url: action, type: this.method, @@ -122,7 +122,8 @@ var FormView = View.extend({ if (this.useMinotaur) { Minotaur.show() } - + + this.beforeSend && this.beforeSend() }, }) @@ -138,4 +139,4 @@ var ModalFormView = ModalView.extend(FormView.prototype).extend({ }) -*/
\ No newline at end of file +*/ diff --git a/views/partials/comments.ejs b/views/partials/comments.ejs index 30f471c..6226a61 100644 --- a/views/partials/comments.ejs +++ b/views/partials/comments.ejs @@ -20,4 +20,16 @@ </td> </tr> </script> +</table> + +<table id="comment_form"> + <tr> + <td> + <form> + <textarea name="comment"></textarea><br> + <input type="file" multiple> + <input type="submit" value="POST" /> + </form> + </td> + </tr> </table>
\ No newline at end of file diff --git a/views/partials/hootbox.ejs b/views/partials/hootbox.ejs index 38d1aa0..d32ff8f 100644 --- a/views/partials/hootbox.ejs +++ b/views/partials/hootbox.ejs @@ -14,4 +14,4 @@ </tr> </script> </table> -</div>
\ No newline at end of file +</div> diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 0a5c4d6..8dc99a1 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -24,6 +24,7 @@ <script src="/assets/js/lib/views/details/comments.js"></script> <script src="/assets/js/lib/views/details/files.js"></script> <script src="/assets/js/lib/views/details/gallery.js"></script> +<script src="/assets/js/lib/views/details/commentform.js"></script> <script src="/assets/js/lib/views/mail/mailbox.js"></script> <script src="/assets/js/lib/views/mail/message.js"></script> diff --git a/views/partials/threads.ejs b/views/partials/threads.ejs index db54445..b3a6e75 100644 --- a/views/partials/threads.ejs +++ b/views/partials/threads.ejs @@ -4,8 +4,7 @@ <script class="keywordTemplate" type="text/html"> <tr class='keyword'> <td> - <b>{{keyword}}</b> - · + <b>{{keyword}}</b> · </td> <td> <a href="/post/{{keyword}}">post</a> |
