Archived
markdown optimization, few other changes
This commit is contained in:
@@ -33,4 +33,11 @@ $(function(){
|
|||||||
$('img').css('transform', 'rotate(180deg)');
|
$('img').css('transform', 'rotate(180deg)');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('pre code').each(function() {
|
||||||
|
if ($(this).attr("class")) {
|
||||||
|
$(this).parent().attr("lang", $(this).attr("class").replace("hljs", "").trim());
|
||||||
|
} else {
|
||||||
|
$(this).parent().attr("lang", "(language unknown)")
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -3,5 +3,5 @@
|
|||||||
*= require style.css
|
*= require style.css
|
||||||
*= require screen.css
|
*= require screen.css
|
||||||
*= require mobi.css
|
*= require mobi.css
|
||||||
*= require highlight/default.css
|
*= require highlight/tomorrow-night.css
|
||||||
*/
|
*/
|
||||||
@@ -230,11 +230,9 @@ and (min-width: 0px) //TODO
|
|||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
background: #3F3F3F;
|
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
box-shadow: 0 0 16px #222 inset;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 1em;
|
background: #3F3F3F;
|
||||||
&:after {
|
&:after {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
content: attr(lang); // show language on top right
|
content: attr(lang); // show language on top right
|
||||||
@@ -252,17 +250,20 @@ and (min-width: 0px) //TODO
|
|||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
background: transparent;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
box-shadow: 0 0 16px #222 inset;
|
||||||
|
background: #3F3F3F !important;
|
||||||
|
border: none;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
background: #3F3F3F;
|
background: #A2A2A2;
|
||||||
padding: 0 2px;
|
padding: 2px 5px 2px 2px;
|
||||||
border-radius: 3px;
|
border-radius: 0 3px 3px 0;
|
||||||
color: #ddd;
|
color: #000;
|
||||||
text-shadow: 1px 1px #000;
|
border-left: 3px solid #3F3F3F;
|
||||||
}
|
}
|
||||||
|
|
||||||
table, tr, td, th {
|
table, tr, td, th {
|
||||||
@@ -271,10 +272,10 @@ and (min-width: 0px) //TODO
|
|||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
background: #F9F9F9;
|
background: #F9F9F9;
|
||||||
border-left: 10px solid #3F3F3F;
|
border-left: 3px solid #3F3F3F;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0 0 0 2em;
|
margin: 0;
|
||||||
padding: 0.5em 3em 0 10px;
|
padding: 2px 5px 2px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote p {
|
blockquote p {
|
||||||
@@ -598,8 +599,17 @@ and (min-width: 0px) //TODO
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
del {
|
iframe.youtube {
|
||||||
background: rgba(255, 200, 200, 0.5);
|
border: none;
|
||||||
|
width: 640px;
|
||||||
|
max-width: 100%;
|
||||||
|
height: 360px;
|
||||||
|
}
|
||||||
|
|
||||||
|
mark {
|
||||||
|
background: #faa;
|
||||||
|
padding: 0 2px;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-counter {
|
.comment-counter {
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ module ApplicationHelper
|
|||||||
lax_spacing: true,
|
lax_spacing: true,
|
||||||
disable_indented_code_blocks: false,
|
disable_indented_code_blocks: false,
|
||||||
space_after_headers: false,
|
space_after_headers: false,
|
||||||
|
superscript: true,
|
||||||
underline: true,
|
underline: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
footnotes: true
|
footnotes: true
|
||||||
})
|
})
|
||||||
md.render(content)
|
render_youtube(md.render(content))
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_mini_md(content)
|
def render_mini_md(content)
|
||||||
@@ -57,10 +58,23 @@ module ApplicationHelper
|
|||||||
lax_spacing: false,
|
lax_spacing: false,
|
||||||
disable_indented_code_blocks: true,
|
disable_indented_code_blocks: true,
|
||||||
space_after_headers: true,
|
space_after_headers: true,
|
||||||
|
superscript: true,
|
||||||
underline: true,
|
underline: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
footnotes: false
|
footnotes: false
|
||||||
})
|
})
|
||||||
md.render(content)
|
md.render(content.gsub(/([\r\n]+\s*?){3,}/, "\n\n").gsub(/^\s*#/, "\\#"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def render_youtube(content)
|
||||||
|
# TODO: render only in text blocks, not in code/quotes/etc
|
||||||
|
return content.gsub(
|
||||||
|
/\[yt:([a-zA-Z0-9\-_]+)\]/,
|
||||||
|
"<iframe class='youtube' allowfullscreen src='
|
||||||
|
https://www.youtube-nocookie.com/embed/\\1?theme=light&vq=hd720&hd=1&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1&html5=1'>
|
||||||
|
</iframe>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
+33
-30
@@ -15,12 +15,12 @@ class User < ActiveRecord::Base
|
|||||||
validates_length_of :password, in: 8..256, :on => :create
|
validates_length_of :password, in: 8..256, :on => :create
|
||||||
validates_length_of :name, in: 2..30
|
validates_length_of :name, in: 2..30
|
||||||
validates_length_of :about, maximum: 5000
|
validates_length_of :about, maximum: 5000
|
||||||
validates_length_of :ign, minimum: 2, maximum: 16
|
validates_length_of :ign, minimum: 1, maximum: 16
|
||||||
|
|
||||||
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@.+\..{2,}\z/i, message: "That doesn't look like an email adress."}
|
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@.+\..{2,}\z/i, message: "That doesn't look like an email adress."}
|
||||||
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "That is probably not your username."}
|
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
|
||||||
|
|
||||||
validate :has_paid, :if => lambda {|user| user.ign_changed? }
|
validate :account_exists?, :if => lambda {|user| user.ign_changed? }
|
||||||
|
|
||||||
has_many :blogposts
|
has_many :blogposts
|
||||||
has_many :comments
|
has_many :comments
|
||||||
@@ -96,31 +96,31 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def haspaid?
|
# def haspaid?
|
||||||
begin
|
# begin
|
||||||
response = open("https://sessionserver.mojang.com/session/minecraft/profile/#{CGI.escape(self.uuid)}", read_timeout: 0.5)
|
# response = open("https://sessionserver.mojang.com/session/minecraft/profile/#{CGI.escape(self.uuid)}", read_timeout: 0.5)
|
||||||
if response.status[0] == "200"
|
# if response.status[0] == "200"
|
||||||
session_profile = JSON.load(response.read)
|
# session_profile = JSON.load(response.read)
|
||||||
# unpaid accounts are called 'demo' accounts
|
# # unpaid accounts are called 'demo' accounts
|
||||||
return session_profile["demo"] == true
|
# return session_profile["demo"] == true
|
||||||
elsif response.status[0] == "204"
|
# elsif response.status[0] == "204"
|
||||||
# user doesn't exist
|
# # user doesn't exist
|
||||||
return false
|
# return false
|
||||||
else
|
# else
|
||||||
puts "---"
|
# puts "---"
|
||||||
puts "ERROR: unexpected response code while checking '#{self.uuid}' for premium account"
|
# puts "ERROR: unexpected response code while checking '#{self.uuid}' for premium account"
|
||||||
puts "code: #{reponse.status}, body: '#{reponse.read}'"
|
# puts "code: #{reponse.status}, body: '#{reponse.read}'"
|
||||||
puts "---"
|
# puts "---"
|
||||||
end
|
# end
|
||||||
rescue => e
|
# rescue => e
|
||||||
puts "---"
|
# puts "---"
|
||||||
puts "ERROR: failed to check for premium account for '#{self.uuid}'. Minecraft servers down?"
|
# puts "ERROR: failed to check for premium account for '#{self.uuid}'. Minecraft servers down?"
|
||||||
puts e.message
|
# puts e.message
|
||||||
puts "---"
|
# puts "---"
|
||||||
end
|
# end
|
||||||
# mojang servers have trouble
|
# # mojang servers have trouble
|
||||||
return true
|
# return true
|
||||||
end
|
# end
|
||||||
|
|
||||||
# def correct_case?(ign)
|
# def correct_case?(ign)
|
||||||
# begin
|
# begin
|
||||||
@@ -183,8 +183,11 @@ class User < ActiveRecord::Base
|
|||||||
self.role ||= Role.get(:normal)
|
self.role ||= Role.get(:normal)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_paid
|
def account_exists?
|
||||||
errors.add(:ign, "'#{self.ign}' is not a paid account!") unless self.haspaid?
|
profile = self.get_profile
|
||||||
|
if !profile || profile["demo"] == true
|
||||||
|
errors.add(:ign, "'#{self.ign}' is not a paid account!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def strip_whitespaces
|
def strip_whitespaces
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ atom_feed do |feed|
|
|||||||
end
|
end
|
||||||
entry.url blogpost_url(post)
|
entry.url blogpost_url(post)
|
||||||
entry.title post.title
|
entry.title post.title
|
||||||
entry.content Sanitize.clean(render_md(post.content), Sanitize::Config::RELAXED).html_safe, :type => 'html'
|
entry.content render_md(post.content).html_safe, :type => 'html'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="item content post">
|
<div class="item content post">
|
||||||
<h2 class="headline"><%= link_to truncate(p.title, length: 60, omission: " …"), p %></h2>
|
<h2 class="headline"><%= link_to truncate(p.title, length: 60, omission: " …"), p %></h2>
|
||||||
<%= Sanitize.clean(render_md(p.content), Sanitize::Config::RELAXED).html_safe %>
|
<%= render_md(p.content).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="item content">
|
<div class="item content">
|
||||||
<h2 class="headline"><%= link_to truncate(@post.title, length: 60, omission: " …"), p %></h2>
|
<h2 class="headline"><%= link_to truncate(@post.title, length: 60, omission: " …"), p %></h2>
|
||||||
<%= Sanitize.clean(render_md(@post.content), Sanitize::Config::RELAXED).html_safe %>
|
<%= render_md(@post.content).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="item content">
|
<div class="item content">
|
||||||
<%= Sanitize.clean(render_mini_md(c.content.gsub(/([\r\n]+\s*?){3,}/, "\n\n")), Sanitize::Config::BASIC).html_safe %>
|
<%= render_mini_md(c.content).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
<h3>New comment</h3>
|
<h3>New comment</h3>
|
||||||
<%= simple_form_for [@post, @comment] do |f| %>
|
<%= simple_form_for [@post, @comment] do |f| %>
|
||||||
<p>> quote | _underline_ | *italic* | **bold** | `code` | [link](https://example.com)
|
<p><blockquote>> quote</blockquote> | _underline_ | <i>*italic*</i> | <b>**bold**</b> | <code>`code`</code> | <mark>==mark==</mark> | <a>[link](https://example.com)</a>
|
||||||
<%= f.input :content, :label => false, :as => "text", :placeholder => "Comment", input_html: {class: "comment"} %>
|
<%= f.input :content, :label => false, :as => "text", :placeholder => "Comment", input_html: {class: "comment"} %>
|
||||||
<%= f.submit class: "btn blue" %>
|
<%= f.submit class: "btn blue" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="item content">
|
<div class="item content">
|
||||||
<h2 class="headline"><%= link_to truncate(@thread.title, length: 60, omission: " …"), p %></h2>
|
<h2 class="headline"><%= link_to truncate(@thread.title, length: 60, omission: " …"), p %></h2>
|
||||||
<%= Sanitize.clean(render_md(@thread.content), Sanitize::Config::RELAXED).html_safe %>
|
<%= render_md(@thread.content).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,5 +82,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
About:<br>
|
About:<br>
|
||||||
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : @user.about %>
|
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : render_mini_md(@user.about).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user