Browse Source

markdown via redcarpet

master
naomiEve 4 years ago
parent
commit
555fd88e59
4 changed files with 13 additions and 3 deletions
  1. +1
    -0
      create.sql
  2. +2
    -1
      src/routes/augmented.rb
  3. +9
    -1
      src/static/static/augmented.css
  4. +1
    -1
      src/views/aug_article.erb

+ 1
- 0
create.sql View File

@ -7,6 +7,7 @@ CREATE TABLE posts (
title TEXT,
content TEXT NOT NULL,
description TEXT,
attach TEXT,
author TEXT NOT NULL,
is_op BOOLEAN NOT NULL,
is_signed_author BOOLEAN,


+ 2
- 1
src/routes/augmented.rb View File

@ -7,6 +7,7 @@
require 'mysql2'
require 'sanitize'
require 'redcarpet'
def make_con()
return Mysql2::Client.new(:host => "localhost", :username => "augmented", :password => "augmented", :database => "augmented")
@ -102,7 +103,7 @@ module Sinatra
end
app.get "/article/:id" do |id|
erb :aug_article, :locals => {:con => make_con(), :id => id}
erb :aug_article, :locals => {:con => make_con(), :id => id, :markdown => Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)}
end
app.get "/tag/:tag" do |tag|


+ 9
- 1
src/static/static/augmented.css View File

@ -82,7 +82,7 @@ pre {
#articlecontainer {
text-align: left;
margin-left: 10px;
margin-top: 20px;
margin-top: 30px;
margin-right: 10px;
}
@ -109,3 +109,11 @@ pre {
.label {
color: #FFF;
}
textarea, form > input[type='text'] {
resize: none;
background-color: #262626;
color: white;
border: none;
border-radius: 4px;
}

+ 1
- 1
src/views/aug_article.erb View File

@ -19,7 +19,7 @@
<div id="articlecontainer">
<div class="title"><%= Sanitize.clean(res["title"]) %></div>
<div class="author">By <%= Sanitize.clean(res["author"]) %></div>
<pre id="content"><%= Sanitize.clean(res["content"]) %></pre>
<pre id="content"><%= markdown.render(Sanitize.clean(res["content"])) %></pre>
</div>
<div class="meta">This article was filed under <a href="/tag/<%= Sanitize.clean(res["tag"]) %>">#<%= Sanitize.clean(res["tag"]) %></a></div>
<% end %>


Loading…
Cancel
Save