Skip to content

Commit

Permalink
修复若干bug
Browse files Browse the repository at this point in the history
  • Loading branch information
oranzhang committed Jul 31, 2014
1 parent dfed5e4 commit f74c05e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gather/app/assets/javascripts/topic.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ self.topic = {
submit_content = (node)->
b64 = new Base64()
dataa = {
title: $("#new-topic-title")[0].value,
title: emoji.replace_colons(emoji.replace_unified($("#new-topic-title")[0].value)),
content: ali.replace_colons(emoji.replace_colons(emoji.replace_unified($("#new-topic-content")[0].value))),
node: node
}
Expand Down
6 changes: 6 additions & 0 deletions Gather/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,9 @@ html {
background: 0;
color: white;
}
.topic-list-title img, #page-title img {
height: 1em;
}
.inner-box img {
max-width: 90%;
}
32 changes: 31 additions & 1 deletion Gather/app/helpers/topic_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,37 @@ def parse_content c
end
@rca << '<p>' + (@sa.join ' ') + '</p>'
end
@rca.join

Sanitize.fragment(@rca.join, Sanitize::Config.merge(Sanitize::Config::BASIC,
:elements => ['img', 'p', 'a'],
:remove_contents => false,
:attributes => {
'img' => ['alt', 'src', 'title'],
'p' => [],
'a' => ["href"]
}
))
end
def parse_title c
@sa = []
c.split(" ").each do |x|
#Urls and Images
@x = x.html_safe
@t = x.html_safe
if !@t.gsub! /^(http:\/\/|https:\/\/|\/){1}([a-zA-z0-9]|\.|\-|\/|\%|\?|\$)+(\.jpg|\.png|\.svg|\.gif|\.jpeg|\.bmp)$/ , '<img src="\0" / >'
if !@t.gsub! /^(http|https):\/\/([a-zA-z0-9]|\.|\-|\/|\%|\?|\$)+$/, '<a href="\0">\0</a>'
@t = @x
end
end
@sa << @t
end
Sanitize.fragment((@sa.join ' '), Sanitize::Config.merge(Sanitize::Config::BASIC,
:elements => ['img'],
:remove_contents => false,
:attributes => {
'img' => ['alt', 'src', 'title']
}
))
end
# def simple_helper_method
# ...
Expand Down
2 changes: 1 addition & 1 deletion Gather/app/views/topic/list.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ p#page-title Topics
a href=("/user/" + p.user.name)
==avatar p.user.email, 80
.topic-list-info
p.topic-list-title=link_to p.title, '/topic/view/' + p.id
p.topic-list-title==link_to (parse_title p.title).html_safe, '/topic/view/' + p.id
p.topic-list-description
== icon('user') + " " + link_to(p.user.name, "/user/" + p.user.name) + " " + icon('clock-o') + " " + timeago(p.created_at)+ " " + icon('comments-o') + " " + timeago(p.last_replied_at)
p.page-ctrl
Expand Down
2 changes: 1 addition & 1 deletion Gather/app/views/topic/list_node.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ p#[email protected]
a href=("/user/" + p.user.name)
==avatar p.user.email, 80
.topic-list-info
p.topic-list-title=link_to p.title, '/topic/view/' + p.id
p.topic-list-title==link_to (parse_title p.title).html_safe, '/topic/view/' + p.id
p.topic-list-description
== icon('user') + " " + link_to(p.user.name, "/user/" + p.user.name) + " " + icon('clock-o') + " " + timeago(p.created_at)+ " " + icon('comments-o') + " " + timeago(p.last_replied_at)
p.page-ctrl
Expand Down
2 changes: 1 addition & 1 deletion Gather/app/views/topic/view.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-t = @t
p#page-title=t.title
p#page-title==parse_title t.title
.container
.inner-box.topic-content data-id=(t.id.to_s)
.topic-avatar.f-right
Expand Down
6 changes: 3 additions & 3 deletions Gather/app/views/user/view.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ p#[email protected]
.view-list
h1=@u.name + "'s Topics"
hr.no-view
- @u.topics.page(1).each do |t|
- @u.topics.desc(:last_replied_at).page(1).each do |t|
.topic-list-item
.topic-list-count=link_to get_reply_count(t.id),'/topic/view/' + t.id
.topic-list-count==link_to get_reply_count(t.id),'/topic/view/' + t.id
.topic-list-avatar
a href=("/user/" + t.user.name)
==avatar t.user.email, 80
.topic-list-info
p.topic-list-title=link_to t.title, '/topic/view/' + t.id
p.topic-list-title=link_to (parse_title t.title).html_safe, '/topic/view/' + t.id
p.topic-list-description
== icon('user') + " " + link_to(t.user.name, "/user/" + t.user.name) + " " + icon('clock-o') + " " + timeago(t.created_at)+ " " + icon('comments-o') + " " + timeago(t.last_replied_at)
4 changes: 3 additions & 1 deletion Gather/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class User

validates_presence_of :name, :email, :salt, :hashed_password
validates_uniqueness_of :name, :email

validates_format_of :name, :with => /([a-zA-z0-9]|\.|-|_)+/
validates_format_of :email, :with => /([a-zA-z0-9]|\.|-|_)+\@([a-zA-z0-9]|\.|-|_)+\.([a-zA-z0-9]|\.|-|_)+/

def self.get(hash)
user = self.where(hash)
if user.exists?
Expand Down

0 comments on commit f74c05e

Please sign in to comment.