EliteJournal 1.9.400
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/MIT-LICENSE +21 -0
- data/README +22 -0
- data/app/controllers/account_controller.rb +25 -0
- data/app/controllers/application.rb +83 -0
- data/app/controllers/atom_controller.rb +26 -0
- data/app/controllers/auth_controller.rb +23 -0
- data/app/controllers/backend_controller.rb +14 -0
- data/app/controllers/css_controller.rb +31 -0
- data/app/controllers/draft_controller.rb +62 -0
- data/app/controllers/image_controller.rb +11 -0
- data/app/controllers/journal_controller.rb +53 -0
- data/app/controllers/link_controller.rb +29 -0
- data/app/controllers/ping_controller.rb +44 -0
- data/app/controllers/post_controller.rb +131 -0
- data/app/controllers/rss_controller.rb +22 -0
- data/app/controllers/tags_controller.rb +74 -0
- data/app/controllers/user_controller.rb +30 -0
- data/app/controllers/users_controller.rb +13 -0
- data/app/helpers/account_helper.rb +2 -0
- data/app/helpers/application_helper.rb +117 -0
- data/app/helpers/atom_helper.rb +2 -0
- data/app/helpers/auth_helper.rb +2 -0
- data/app/helpers/backend_helper.rb +2 -0
- data/app/helpers/css_helper.rb +2 -0
- data/app/helpers/draft_helper.rb +2 -0
- data/app/helpers/image_helper.rb +2 -0
- data/app/helpers/journal_helper.rb +2 -0
- data/app/helpers/link_helper.rb +2 -0
- data/app/helpers/ping_helper.rb +5 -0
- data/app/helpers/post_helper.rb +2 -0
- data/app/helpers/rss_helper.rb +5 -0
- data/app/helpers/tags_helper.rb +7 -0
- data/app/helpers/user_helper.rb +2 -0
- data/app/helpers/users_helper.rb +2 -0
- data/app/models/blogger_api.rb +24 -0
- data/app/models/comment.rb +18 -0
- data/app/models/draft.rb +12 -0
- data/app/models/face.rb +24 -0
- data/app/models/feed_killer.rb +17 -0
- data/app/models/image.rb +7 -0
- data/app/models/link.rb +10 -0
- data/app/models/meta_weblog_api.rb +82 -0
- data/app/models/ping.rb +16 -0
- data/app/models/post.rb +30 -0
- data/app/models/stylesheet.rb +7 -0
- data/app/models/tag.rb +16 -0
- data/app/models/user.rb +35 -0
- data/app/views/account/info.rhtml +30 -0
- data/app/views/atom/feed.rxml +15 -0
- data/app/views/auth/login.rhtml +9 -0
- data/app/views/css/edit.rhtml +18 -0
- data/app/views/css/list.rhtml +24 -0
- data/app/views/css/new.rhtml +6 -0
- data/app/views/draft/edit.rhtml +9 -0
- data/app/views/draft/list.rhtml +22 -0
- data/app/views/draft/new.rhtml +9 -0
- data/app/views/journal/_comment.rhtml +10 -0
- data/app/views/journal/_post.rhtml +40 -0
- data/app/views/journal/_trackback.rhtml +4 -0
- data/app/views/journal/error.rhtml +1 -0
- data/app/views/journal/index.rhtml +1 -0
- data/app/views/journal/view.rhtml +15 -0
- data/app/views/layouts/application.rhtml +90 -0
- data/app/views/link/list.rhtml +19 -0
- data/app/views/link/new.rhtml +7 -0
- data/app/views/ping/trackback.rxml +4 -0
- data/app/views/post/_reply.rhtml +10 -0
- data/app/views/post/destroyxml.rxml +3 -0
- data/app/views/post/edit.rhtml +7 -0
- data/app/views/post/new.rhtml +13 -0
- data/app/views/post/postxml.rxml +7 -0
- data/app/views/post/reply.rhtml +33 -0
- data/app/views/post/replyxml.rxml +5 -0
- data/app/views/post/toggle_commentingxml.rxml +9 -0
- data/app/views/rss/index.rxml +15 -0
- data/app/views/tags/addxml.rxml +4 -0
- data/app/views/tags/index.rhtml +3 -0
- data/app/views/tags/no_completions.rhtml +1 -0
- data/app/views/tags/search.rhtml +10 -0
- data/app/views/tags/search_completer.rhtml +1 -0
- data/app/views/user/list.rhtml +21 -0
- data/app/views/user/new.rhtml +12 -0
- data/app/views/users/index.rhtml +6 -0
- data/config/app.yml +15 -0
- data/config/database.yml +17 -0
- data/config/environment.rb +58 -0
- data/config/environments/development.rb +5 -0
- data/config/environments/geminstall.rb +4 -0
- data/config/environments/production.rb +3 -0
- data/config/environments/shared.rb +17 -0
- data/config/environments/test.rb +3 -0
- data/db/db-mysql.sql +95 -0
- data/db/db-postgresql.sql +94 -0
- data/db/db-sqlite.sql +94 -0
- data/db/default_user.sql +1 -0
- data/db/development_structure.sql +257 -0
- data/elitejournal +132 -0
- data/lib/image_size.rb +277 -0
- data/lib/trackback.rb +45 -0
- data/public/404.html +6 -0
- data/public/500.html +6 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +7 -0
- data/public/dispatch.rb +10 -0
- data/public/stylesheets/ej-layout.css +126 -0
- data/public/stylesheets/ej-style.css +105 -0
- data/public/stylesheets/undohtml.css +9 -0
- metadata +178 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
require_dependency 'trackback'
|
2
|
+
|
3
|
+
class PostController < ApplicationController
|
4
|
+
before_filter :auth_required, :except => :reply
|
5
|
+
cache_sweeper :feed_killer, :only => [:new, :edit, :destroy, :destroyxml]
|
6
|
+
|
7
|
+
def index
|
8
|
+
redirect_to :action => 'new'
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@post = Post.new
|
13
|
+
|
14
|
+
if @request.post?
|
15
|
+
@post.attributes = @params['post']
|
16
|
+
@post.user = current_user
|
17
|
+
@post.allows_comment = current_user.allows_comment?
|
18
|
+
if @post.save
|
19
|
+
# Hook up the tags
|
20
|
+
unless @params['tags'].empty?
|
21
|
+
@params['tags'].split(',').collect {|t| t.strip}.uniq.each do |tag|
|
22
|
+
thetag = Tag.find_by_tag(tag) || Tag.new('tag' => tag)
|
23
|
+
thetag.increment('numitems')
|
24
|
+
thetag.save
|
25
|
+
@post.tags << thetag
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# Check for trackback.
|
29
|
+
send_trackback(@post, @params['tb_url'], @app_config) unless @params['tb_url'].empty?
|
30
|
+
redirect_to :controller => 'users', :action => @post.user.username
|
31
|
+
return
|
32
|
+
end
|
33
|
+
@error = @post.errors.full_messages
|
34
|
+
return
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit
|
39
|
+
begin
|
40
|
+
@post = current_user.posts.find(@params['id'])
|
41
|
+
rescue ActiveRecord::RecordNotFound
|
42
|
+
redirect_to_main
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
if @request.post?
|
47
|
+
@post.attributes = @params['post']
|
48
|
+
if @post.save
|
49
|
+
flash['notice'] = "Post was successfully saved."
|
50
|
+
redirect_to_main
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def postxml
|
56
|
+
@post = current_user.posts.find(@params['id']) rescue Post.new
|
57
|
+
@post.update_attributes @params['post'] if @request.post?
|
58
|
+
render_without_layout 'post/postxml'
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
current_user.posts.find(@params['id']).destroy rescue nil
|
63
|
+
redirect_to_main
|
64
|
+
end
|
65
|
+
|
66
|
+
def destroyxml
|
67
|
+
@postid = @params['id']
|
68
|
+
current_user.posts.find(@params['id']).destroy rescue nil
|
69
|
+
end
|
70
|
+
|
71
|
+
def destroy_comment
|
72
|
+
Comment.find(@params['id']).destroy rescue nil
|
73
|
+
redirect_to @request.env['HTTP_REFERER']
|
74
|
+
end
|
75
|
+
|
76
|
+
def toggle_commenting
|
77
|
+
if (post = current_user.posts.find(@params['id']) rescue nil)
|
78
|
+
post.allows_comment = (not post.allows_comment?)
|
79
|
+
post.save
|
80
|
+
end
|
81
|
+
redirect_to @request.env['HTTP_REFERER']
|
82
|
+
end
|
83
|
+
|
84
|
+
def toggle_commentingxml
|
85
|
+
if (@post = current_user.posts.find(@params['id']) rescue nil)
|
86
|
+
@post.allows_comment = (not @post.allows_comment?)
|
87
|
+
@post.save
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def reply
|
92
|
+
begin
|
93
|
+
@post = Post.find(@params['id'])
|
94
|
+
@user = @post.user
|
95
|
+
unless @post.allows_comment?
|
96
|
+
redirect_to :controller => 'journal', :action => 'view', :id => @post.id
|
97
|
+
return
|
98
|
+
end
|
99
|
+
|
100
|
+
@comments = @post.find_all_in_comments("comment_id=0")
|
101
|
+
|
102
|
+
if @request.post?
|
103
|
+
@newcomment = @post.comments.create(@params['newcomment'])
|
104
|
+
unless @newcomment.save
|
105
|
+
@error = @newcomment.errors.full_messages
|
106
|
+
render 'journal/error'
|
107
|
+
return
|
108
|
+
end
|
109
|
+
redirect_to :controller => 'journal', :action => 'view', :id => @newcomment.post_id
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
# A little hack to pre-load the subject line.
|
114
|
+
# Do this down here so it doesn't get called for the POST.
|
115
|
+
@newcomment = Comment.new('subject' => 'Re: ' + @post.subject)
|
116
|
+
if @params['comment_id']
|
117
|
+
@comment = Comment.find(@params['comment_id'])
|
118
|
+
end
|
119
|
+
|
120
|
+
rescue ActiveRecord::RecordNotFound
|
121
|
+
redirect_to_main
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def replyxml
|
126
|
+
@post = Post.find(@params['id'])
|
127
|
+
@params['comment']['body'].strip! # what the fuck, safari? \000?
|
128
|
+
@comment = @post.comments.create(@params['comment'])
|
129
|
+
render_without_layout 'journal/replyxml'
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class RssController < ApplicationController
|
2
|
+
layout nil
|
3
|
+
caches_page :index
|
4
|
+
|
5
|
+
def index
|
6
|
+
@posts = Post.find_all(nil, 'updated_at DESC', @app_config['main']['num_posts'])
|
7
|
+
@title = @app_config['main']['title']
|
8
|
+
@subtitle = @app_config['main']['subtitle']
|
9
|
+
end
|
10
|
+
|
11
|
+
# +method_missing+ provides the convenient /atom/username URLs to
|
12
|
+
# access a user's feed. If a non-existent user is passed, it will
|
13
|
+
# just return an empty feed.
|
14
|
+
def method_missing(method)
|
15
|
+
user = User.find_by_username(method.to_s)
|
16
|
+
@title = user.title
|
17
|
+
@subtitle = user.subtitle
|
18
|
+
@posts = user.posts.find_all(nil, 'created_at desc', @app_config['main']['num_posts']) rescue []
|
19
|
+
render_action 'index'
|
20
|
+
cache_page if ActionController::Base.perform_caching
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class TagsController < ApplicationController
|
2
|
+
def index
|
3
|
+
@tags = Tag.find_all(nil, 'tag')
|
4
|
+
end
|
5
|
+
|
6
|
+
def show
|
7
|
+
@tag = Tag.find_by_tag(CGI.unescape(@params['tag'])) rescue Tag.new
|
8
|
+
@posts = @tag.posts
|
9
|
+
render 'journal/index'
|
10
|
+
end
|
11
|
+
|
12
|
+
def add
|
13
|
+
post = Post.find(@params['post_id'])
|
14
|
+
post_tags = post.tags.collect { |t| t.tag }
|
15
|
+
unless @params['tags'].empty?
|
16
|
+
@params['tags'].split(',').each do |tag|
|
17
|
+
unless post_tags.include? tag.strip
|
18
|
+
thetag = Tag.find_by_tag(tag.strip) || Tag.new('tag' => tag.strip)
|
19
|
+
thetag.increment('numitems')
|
20
|
+
thetag.save
|
21
|
+
post.tags << thetag
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
redirect_to :controller => 'journal', :action => 'view', :id => post.id
|
26
|
+
end
|
27
|
+
|
28
|
+
def addxml
|
29
|
+
@post = Post.find(@params['post_id'])
|
30
|
+
post_tags = @post.tags.collect { |t| t.tag }
|
31
|
+
unless @params['tags'].empty?
|
32
|
+
@params['tags'].split(',').each do |tag|
|
33
|
+
unless post_tags.include? tag.strip
|
34
|
+
thetag = Tag.find_by_tag(tag.strip) || Tag.new('tag' => tag.strip)
|
35
|
+
thetag.increment('numitems')
|
36
|
+
thetag.save
|
37
|
+
@post.tags << thetag
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
render_without_layout 'tags/addxml'
|
42
|
+
end
|
43
|
+
|
44
|
+
def search
|
45
|
+
if @params['qu']
|
46
|
+
if /,\W*$/ =~ @params['qu']
|
47
|
+
render_without_layout 'tags/no_completions'
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
items = @params['qu'].split(',')
|
52
|
+
item = items[-1].strip
|
53
|
+
|
54
|
+
if items.length > 1
|
55
|
+
notin = "AND tag NOT IN ("
|
56
|
+
notin += items[0...-1].collect {|t| "'#{t.strip}'"}.join(',') + ")"
|
57
|
+
else
|
58
|
+
notin = ''
|
59
|
+
end
|
60
|
+
if item != ''
|
61
|
+
@tags = Tag.find_all("tag LIKE '#{item}%' #{notin}", 'tag')
|
62
|
+
else
|
63
|
+
@tags = []
|
64
|
+
end
|
65
|
+
|
66
|
+
@tagarray = @tags.collect { |t| "\"#{t.tag}\"" }.join(', ')
|
67
|
+
@postsarray = @tags.collect { |t| "\"#{t.posts_count} posts\"" }.join(', ')
|
68
|
+
|
69
|
+
render_without_layout 'tags/search_completer'
|
70
|
+
else
|
71
|
+
render_without_layout 'tags/search'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class UserController < ApplicationController
|
2
|
+
before_filter :auth_required
|
3
|
+
before_filter :admin_required
|
4
|
+
|
5
|
+
def index
|
6
|
+
list
|
7
|
+
render_action 'list'
|
8
|
+
end
|
9
|
+
|
10
|
+
def list
|
11
|
+
@users = User.find_all(nil, 'name')
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@user = User.new
|
16
|
+
if @request.post?
|
17
|
+
@user.attributes = @params['user']
|
18
|
+
if @user.save
|
19
|
+
flash['notice'] = "User was successfully saved."
|
20
|
+
redirect_to_user
|
21
|
+
return
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy
|
27
|
+
User.find(@params['id']).destroy rescue nil
|
28
|
+
redirect_to_user
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
def index
|
3
|
+
@users = User.find_all nil, 'username'
|
4
|
+
end
|
5
|
+
|
6
|
+
def method_missing(method)
|
7
|
+
@user = User.find_by_username(method.to_s)
|
8
|
+
redirect_to_main and return unless @user
|
9
|
+
@posts = @user.posts.find_all(nil, 'created_at desc', @app_config['main']['num_posts'])
|
10
|
+
|
11
|
+
render 'journal/index'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# The methods added to this helper will be available to all templates in the application.
|
2
|
+
module ApplicationHelper
|
3
|
+
def link_to_year(year)
|
4
|
+
content_tag "a", year, {'href'=> @app_config['main']['app_base'] + year}
|
5
|
+
end
|
6
|
+
|
7
|
+
def link_to_month(year, month, name)
|
8
|
+
content_tag "a", name, {'href'=> @app_config['main']['app_base'] + year + '/' + month}
|
9
|
+
end
|
10
|
+
|
11
|
+
def link_to_day(year, month, day, name)
|
12
|
+
content_tag "a", name, {'href'=> @app_config['main']['app_base'] + year + '/' + month + '/' + day}
|
13
|
+
end
|
14
|
+
|
15
|
+
def sexifytime(t)
|
16
|
+
day = case t.day % 10
|
17
|
+
when 0
|
18
|
+
"#{t.day}th"
|
19
|
+
when 1
|
20
|
+
"#{t.day}st"
|
21
|
+
when 2
|
22
|
+
"#{t.day}nd"
|
23
|
+
when 3
|
24
|
+
"#{t.day}rd"
|
25
|
+
else
|
26
|
+
"#{t.day}th"
|
27
|
+
end
|
28
|
+
|
29
|
+
day = "#{t.day}th" if [12, 13, 14].include? t.day
|
30
|
+
|
31
|
+
|
32
|
+
str = ''
|
33
|
+
str << link_to_day(t.strftime('%Y'), t.strftime('%m'), t.strftime('%d'), day) << ' '
|
34
|
+
str << link_to_month(t.strftime('%Y'), t.strftime('%m'), t.strftime('%B')) << ' '
|
35
|
+
str << link_to_year(t.strftime('%Y')) << ', '
|
36
|
+
|
37
|
+
str << case t.hour
|
38
|
+
when 0..2
|
39
|
+
'the wee hours'
|
40
|
+
when 3..6
|
41
|
+
'terribly early in the morning'
|
42
|
+
when 7..9
|
43
|
+
'early morning'
|
44
|
+
when 10
|
45
|
+
'mid-morning'
|
46
|
+
when 11
|
47
|
+
'late morning'
|
48
|
+
when 12..13
|
49
|
+
'lunch time'
|
50
|
+
when 14
|
51
|
+
'early afternoon'
|
52
|
+
when 15..16
|
53
|
+
'mid-afternoon'
|
54
|
+
when 17
|
55
|
+
'late afternoon'
|
56
|
+
when 18..19
|
57
|
+
'early evening'
|
58
|
+
when 20..21
|
59
|
+
'evening time'
|
60
|
+
when 22
|
61
|
+
'late evening'
|
62
|
+
when 23
|
63
|
+
'late at night'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def link_user(user, text=user.name)
|
68
|
+
link_to text, :controller => 'users', :action => user.username
|
69
|
+
end
|
70
|
+
|
71
|
+
def tag_links(post, limit = nil)
|
72
|
+
tags = post.tags.sort_by {|tag| tag.numitems}.reverse.map { |tag| link_to(tag.tag, :controller => 'tags', :action => 'show', :params => {'tag' => CGI.escape(tag.tag)}) }
|
73
|
+
(limit ? tags.first(limit) : tags ).join(', ')
|
74
|
+
end
|
75
|
+
|
76
|
+
def comment_toggle_link(post)
|
77
|
+
text = post.allows_comment? ? 'Disallow Comments' : 'Allow Comments'
|
78
|
+
link_to(text, {:controller => 'post', :action => 'toggle_commenting', :id => post.id}, {'onclick' => "return toggleCommenting('#{post.id}')"})
|
79
|
+
end
|
80
|
+
|
81
|
+
def post_links(post)
|
82
|
+
if post.allows_comment?
|
83
|
+
disp = ''
|
84
|
+
else
|
85
|
+
disp = 'style="display: none;"'
|
86
|
+
end
|
87
|
+
|
88
|
+
str = '<ul class="postlinks">'
|
89
|
+
str << "<li #{disp} id=\"replylink_#{post.id}\">" + link_to('Reply', {:controller => 'post', :action => 'reply', :id => post.id}, 'onclick' => "return showReply('#{post.id}')", 'id' => "post_reply_#{post.id}") + "</li>"
|
90
|
+
str << '<li>' + link_to('Add Tags', {:controller => 'post', :action => 'tag', :id => post.id}, 'onclick' => "return showTagger('#{post.id}')", 'id' => "post_tagger_#{post.id}") + '</li>'
|
91
|
+
str << '<li>' + link_to("View / Permalink", {:controller => 'view', :action => post.id.to_s}, {'class' => 'middle' }) + '</li>'
|
92
|
+
str << "<li #{disp} id=\"comment_count_#{post.id}\"> " + link_to("Comments (#{post.comments.length})", :controller => 'view', :action => post.id.to_s, :anchor => 'comments') + "</li>"
|
93
|
+
str << "<li>" + link_to("Trackbacks (#{post.pings.length})", :controller => 'view', :action => post.id.to_s, :anchor => 'trackbacks') + "</li>"
|
94
|
+
str << '</ul>'
|
95
|
+
end
|
96
|
+
|
97
|
+
def render_body(post)
|
98
|
+
unless ['view', 'reply'].include? @params['action']
|
99
|
+
return post.sections.first + (post.sections.length > 1 ? '<p><strong>Read More ...</strong></p>' : '')
|
100
|
+
end
|
101
|
+
post.rendered
|
102
|
+
end
|
103
|
+
|
104
|
+
def user_face(user)
|
105
|
+
return nil unless user.has_face?
|
106
|
+
image = %{<img class="user_face" src="/image/face/#{user.id}" height="#{user.face.height}" width="#{user.face.width}" />}
|
107
|
+
link_user(user, image)
|
108
|
+
end
|
109
|
+
|
110
|
+
def page_title()
|
111
|
+
user_page? ? @user.title : @app_config['main']['title']
|
112
|
+
end
|
113
|
+
|
114
|
+
def page_subtitle()
|
115
|
+
user_page? ? @user.subtitle : @app_config['main']['subtitle']
|
116
|
+
end
|
117
|
+
end
|