From: Ian Kelling Date: Tue, 4 Oct 2016 07:37:00 +0000 (-0700) Subject: fix comment formatting regression from safe markup X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=a5d36b23813ae286ba3fb76e4f60ef6d267ba128;p=iankelling.org fix comment formatting regression from safe markup --- diff --git a/_site/cgi/comment b/_site/cgi/comment index 4b14c3c..b84c45e 100755 --- a/_site/cgi/comment +++ b/_site/cgi/comment @@ -142,6 +142,10 @@ if COMMENT_TXT.length > 1000 or GOTO.length > 150 fail('length of comment or goto is too great') end +if COMMENT_TXT.length <= 2 or COMMENT_TXT =~ /\A\s*\Z/ + fail('not enough content in comment') +end + captchad = false if cgi.has_key?('answer') && cgi.has_key?('question') @@ -300,7 +304,7 @@ $db.execute('insert into c values (NULL, ?, ?, ?, ?, ?)', COMMENT_TXT]) if date - new_count = $db.execute(query + 'and date > ?',date) + new_count = $db.execute(query + 'and date > ?', date) else new_count = $db.execute(query) end @@ -328,7 +332,7 @@ END_OF_MESSAGE smtp.send_message msg, opts[:from], opts[:to] end end - send_email :subject => 'new comments on iankelling.org' + send_email :subject => "new comment on #{DN}" end post(md_file) diff --git a/b.rb b/b.rb index 2dc8ad8..c2dbc75 100644 --- a/b.rb +++ b/b.rb @@ -125,15 +125,14 @@ EOF end def comment_html(comment, date) - inner = Redcarpet::Markdown.new(Redcarpet::Render::Safe, fenced_code_blocks: true).render(<#{Time.at(date).strftime("%b %-d '%y")} -EOF # I tried putting the time, %I:%M %p UTC, but it looks kinda # clunky, going against my simple theme. + user_input = Redcarpet::Markdown.new(Redcarpet::Render::Safe, + fenced_code_blocks: true).render(comment) < - #{inner} + #{user_input} +

#{Time.at(date).strftime("%b %-d '%y")}

EOF end diff --git a/comments/blog/site-redesign.html/1475551365.0383508 b/comments/blog/site-redesign.html/1475551365.0383508 new file mode 100755 index 0000000..3f2cca6 --- /dev/null +++ b/comments/blog/site-redesign.html/1475551365.0383508 @@ -0,0 +1 @@ +Sample comment with *formatting*. \ No newline at end of file diff --git a/css/main.scss b/css/main.scss index c878224..7c7e4a2 100644 --- a/css/main.scss +++ b/css/main.scss @@ -80,16 +80,10 @@ body { line-height: 1.5; // default is too scrunched } -// alternative to a
. whatever. -// https://stackoverflow.com/questions/7363766/how-to-insert-a-line-break-before-an-element-using-css -.comment-date::before { - content: "\A"; -} - .comment-date { color: $comment-date-color; font-size: 15px; - white-space: pre; + margin-top: 0; } .post-date { diff --git a/get-comments b/get-comments index 54ea99a..0710319 100755 --- a/get-comments +++ b/get-comments @@ -24,7 +24,7 @@ shell="ssh $(chost iankelling.org)" while [[ $1 ]]; do case $1 in -a) all=true; shift ;; - -l) shell= ; shift ;; # -l for local + -l) shell= ; shift ;; # -l for local site instead of iankelling.org esac done diff --git a/iank-mod.el b/iank-mod.el index 4faea5f..b033cbc 100644 --- a/iank-mod.el +++ b/iank-mod.el @@ -13,14 +13,24 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -(defun iankmod-start () - (interactive) - (shell-command "/a/h/get-comments" "*messages*") - (find-file "/tmp/hcomments") - (iankmod 1)) + +;; generally, use m-x iankmod-start. c-u to run on local testing +;; instance. Alternatively, run get-comments with whatever args, +;; manually open /tmp/hcomments, then run (iankmod). + +(defun iankmod-start (arg) + (interactive "P") + (setq iankmod-last-arg (if (equal arg '(4)) " -l" "")) + (let ((cmd (concat "/a/h/get-comments" iankmod-last-arg))) + (shell-command cmd "*messages*") + (find-file "/tmp/hcomments") + (iankmod 1))) + (defun iankmod-save () (interactive) - (shell-command "/a/h/set-comments" "*messages*")) + (basic-save-buffer) + (let ((cmd (concat "/a/h/set-comments" iankmod-last-arg))) + (shell-command cmd "*messages*"))) (defun iankmod-set-state (state) diff --git a/setup.sh b/setup.sh index deb61b9..cfcee75 100755 --- a/setup.sh +++ b/setup.sh @@ -29,6 +29,7 @@ gitroot=/a/bin/githtml shopt -s extglob type -P a2enmod &>/dev/null || pi apache2 +type -P sqlite3 &>/dev/null || pi sqlite3 acme-tiny-wrapper $domain