rethoth 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/bin/thoth +233 -0
- data/lib/proto/config.ru +45 -0
- data/lib/proto/thoth.conf.sample +206 -0
- data/lib/thoth/cache.rb +53 -0
- data/lib/thoth/config.rb +158 -0
- data/lib/thoth/controller/admin.rb +75 -0
- data/lib/thoth/controller/api/comment.rb +73 -0
- data/lib/thoth/controller/api/page.rb +134 -0
- data/lib/thoth/controller/api/post.rb +122 -0
- data/lib/thoth/controller/api/tag.rb +59 -0
- data/lib/thoth/controller/archive.rb +50 -0
- data/lib/thoth/controller/comment.rb +173 -0
- data/lib/thoth/controller/main.rb +193 -0
- data/lib/thoth/controller/media.rb +172 -0
- data/lib/thoth/controller/page.rb +167 -0
- data/lib/thoth/controller/post.rb +310 -0
- data/lib/thoth/controller/search.rb +86 -0
- data/lib/thoth/controller/tag.rb +107 -0
- data/lib/thoth/controller.rb +48 -0
- data/lib/thoth/errors.rb +35 -0
- data/lib/thoth/helper/admin.rb +86 -0
- data/lib/thoth/helper/cookie.rb +45 -0
- data/lib/thoth/helper/error.rb +122 -0
- data/lib/thoth/helper/pagination.rb +131 -0
- data/lib/thoth/helper/wiki.rb +77 -0
- data/lib/thoth/helper/ysearch.rb +89 -0
- data/lib/thoth/importer/pants.rb +81 -0
- data/lib/thoth/importer/poseidon.rb +54 -0
- data/lib/thoth/importer/thoth.rb +103 -0
- data/lib/thoth/importer.rb +131 -0
- data/lib/thoth/layout/default.rhtml +47 -0
- data/lib/thoth/middleware/minify.rb +82 -0
- data/lib/thoth/migrate/001_create_schema.rb +108 -0
- data/lib/thoth/migrate/002_add_media_size.rb +37 -0
- data/lib/thoth/migrate/003_add_post_draft.rb +38 -0
- data/lib/thoth/migrate/004_add_comment_email.rb +37 -0
- data/lib/thoth/migrate/005_add_page_position.rb +37 -0
- data/lib/thoth/migrate/006_add_comment_close_delete.rb +43 -0
- data/lib/thoth/migrate/007_add_comment_summary.rb +37 -0
- data/lib/thoth/model/comment.rb +216 -0
- data/lib/thoth/model/media.rb +87 -0
- data/lib/thoth/model/page.rb +204 -0
- data/lib/thoth/model/post.rb +262 -0
- data/lib/thoth/model/tag.rb +80 -0
- data/lib/thoth/model/tags_posts_map.rb +34 -0
- data/lib/thoth/monkeypatch/sequel/model/errors.rb +37 -0
- data/lib/thoth/plugin/thoth_delicious.rb +105 -0
- data/lib/thoth/plugin/thoth_flickr.rb +86 -0
- data/lib/thoth/plugin/thoth_pinboard.rb +98 -0
- data/lib/thoth/plugin/thoth_tags.rb +68 -0
- data/lib/thoth/plugin/thoth_twitter.rb +175 -0
- data/lib/thoth/plugin.rb +59 -0
- data/lib/thoth/public/css/admin.css +223 -0
- data/lib/thoth/public/css/thoth.css +592 -0
- data/lib/thoth/public/images/admin-sprite.png +0 -0
- data/lib/thoth/public/images/thoth-sprite.png +0 -0
- data/lib/thoth/public/js/admin/comments.js +116 -0
- data/lib/thoth/public/js/admin/name.js +244 -0
- data/lib/thoth/public/js/admin/tagcomplete.js +332 -0
- data/lib/thoth/public/js/lazyload-min.js +4 -0
- data/lib/thoth/public/js/thoth.js +203 -0
- data/lib/thoth/public/robots.txt +5 -0
- data/lib/thoth/version.rb +37 -0
- data/lib/thoth/view/admin/index.rhtml +1 -0
- data/lib/thoth/view/admin/login.rhtml +23 -0
- data/lib/thoth/view/admin/toolbar.rhtml +117 -0
- data/lib/thoth/view/admin/welcome.rhtml +58 -0
- data/lib/thoth/view/archive/index.rhtml +24 -0
- data/lib/thoth/view/comment/comment.rhtml +47 -0
- data/lib/thoth/view/comment/delete.rhtml +15 -0
- data/lib/thoth/view/comment/form.rhtml +81 -0
- data/lib/thoth/view/comment/index.rhtml +68 -0
- data/lib/thoth/view/comment/list.rhtml +48 -0
- data/lib/thoth/view/media/delete.rhtml +15 -0
- data/lib/thoth/view/media/edit.rhtml +12 -0
- data/lib/thoth/view/media/form.rhtml +7 -0
- data/lib/thoth/view/media/list.rhtml +35 -0
- data/lib/thoth/view/media/media.rhtml +44 -0
- data/lib/thoth/view/media/new.rhtml +7 -0
- data/lib/thoth/view/page/delete.rhtml +15 -0
- data/lib/thoth/view/page/edit.rhtml +15 -0
- data/lib/thoth/view/page/form.rhtml +57 -0
- data/lib/thoth/view/page/index.rhtml +9 -0
- data/lib/thoth/view/page/list.rhtml +49 -0
- data/lib/thoth/view/page/new.rhtml +15 -0
- data/lib/thoth/view/post/comments.rhtml +12 -0
- data/lib/thoth/view/post/compact.rhtml +48 -0
- data/lib/thoth/view/post/delete.rhtml +15 -0
- data/lib/thoth/view/post/edit.rhtml +15 -0
- data/lib/thoth/view/post/form.rhtml +83 -0
- data/lib/thoth/view/post/index.rhtml +48 -0
- data/lib/thoth/view/post/list.rhtml +61 -0
- data/lib/thoth/view/post/new.rhtml +15 -0
- data/lib/thoth/view/post/tiny.rhtml +4 -0
- data/lib/thoth/view/search/index.rhtml +45 -0
- data/lib/thoth/view/tag/index.rhtml +34 -0
- data/lib/thoth/view/thoth/css.rhtml +9 -0
- data/lib/thoth/view/thoth/footer.rhtml +15 -0
- data/lib/thoth/view/thoth/header.rhtml +23 -0
- data/lib/thoth/view/thoth/index.rhtml +11 -0
- data/lib/thoth/view/thoth/js.rhtml +6 -0
- data/lib/thoth/view/thoth/sidebar.rhtml +38 -0
- data/lib/thoth/view/thoth/util/pager.rhtml +23 -0
- data/lib/thoth/view/thoth/util/simple_pager.rhtml +15 -0
- data/lib/thoth/view/thoth/util/table_sortheader.rhtml +20 -0
- data/lib/thoth.rb +394 -0
- metadata +409 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# Thoth -> Thoth importer (for moving content to a different database).
|
3
|
+
#
|
4
|
+
|
5
|
+
class ThothImporter < Thoth::Importer
|
6
|
+
|
7
|
+
before_import do
|
8
|
+
unless uri = ARGV.shift
|
9
|
+
puts "Please enter a connection string for the Thoth database you want to import."
|
10
|
+
puts "Example: mysql://user:pass@localhost/dbname"
|
11
|
+
print "> "
|
12
|
+
|
13
|
+
uri = STDIN.gets.strip
|
14
|
+
puts
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
@source = Sequel.connect(uri)
|
19
|
+
rescue => e
|
20
|
+
abort("Error: unable to connect to database: #{e}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
import_comments do
|
25
|
+
@source[:comments].each do |row|
|
26
|
+
Thoth::Comment.create do |comment|
|
27
|
+
comment.id = row[:id]
|
28
|
+
comment.author = row[:author]
|
29
|
+
comment.author_url = row[:author_url]
|
30
|
+
comment.author_email = row[:author_email] || 'noemail@noemail.com'
|
31
|
+
comment.title = row[:title]
|
32
|
+
comment.body = row[:body]
|
33
|
+
comment.body_rendered = row[:body_rendered]
|
34
|
+
comment.ip = row[:ip]
|
35
|
+
comment.created_at = row[:created_at]
|
36
|
+
comment.updated_at = row[:updated_at]
|
37
|
+
comment.post_id = row[:post_id]
|
38
|
+
comment.deleted = row[:deleted]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
import_pages do
|
44
|
+
@source[:pages].each do |row|
|
45
|
+
Thoth::Page.create do |page|
|
46
|
+
page.id = row[:id]
|
47
|
+
page.title = row[:title]
|
48
|
+
page.name = row[:name]
|
49
|
+
page.body = row[:body]
|
50
|
+
page.body_rendered = row[:body_rendered]
|
51
|
+
page.created_at = row[:created_at]
|
52
|
+
page.updated_at = row[:updated_at]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
import_posts do
|
58
|
+
@source[:posts].each do |row|
|
59
|
+
Thoth::Post.create do |post|
|
60
|
+
post.id = row[:id]
|
61
|
+
post.title = row[:title]
|
62
|
+
post.name = row[:name]
|
63
|
+
post.body = row[:body]
|
64
|
+
post.body_rendered = row[:body_rendered]
|
65
|
+
post.is_draft = row[:is_draft]
|
66
|
+
post.created_at = row[:created_at]
|
67
|
+
post.updated_at = row[:updated_at]
|
68
|
+
post.allow_comments = row[:allow_comments]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
import_tags do
|
74
|
+
@source[:tags].each do |tag|
|
75
|
+
Thoth.db[:tags] << {
|
76
|
+
:id => tag[:id],
|
77
|
+
:name => tag[:name]
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
@source[:tags_posts_map].each do |tagmap|
|
82
|
+
Thoth.db[:tags_posts_map] << {
|
83
|
+
:id => tagmap[:id],
|
84
|
+
:tag_id => tagmap[:tag_id],
|
85
|
+
:post_id => tagmap[:post_id]
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
import_media do
|
91
|
+
@source[:media].each do |row|
|
92
|
+
Thoth::Media.create do |media|
|
93
|
+
media.id = row[:id]
|
94
|
+
media.filename = row[:filename]
|
95
|
+
media.mimetype = row[:mimetype]
|
96
|
+
media.size = row[:size]
|
97
|
+
media.created_at = row[:created_at]
|
98
|
+
media.updated_at = row[:updated_at]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
module Thoth
|
30
|
+
class Importer
|
31
|
+
include Innate::Traited
|
32
|
+
|
33
|
+
class << self
|
34
|
+
|
35
|
+
def after_import(&block) trait(:after => block); end
|
36
|
+
def before_import(&block) trait(:before => block); end
|
37
|
+
def import_comments(&block) trait(:comments => block); end
|
38
|
+
def import_media(&block) trait(:media => block); end
|
39
|
+
def import_pages(&block) trait(:pages => block); end
|
40
|
+
def import_posts(&block) trait(:posts => block); end
|
41
|
+
def import_tags(&block) trait(:tags => block); end
|
42
|
+
|
43
|
+
def load_importer(name)
|
44
|
+
importer = name.to_s.downcase.strip.gsub(/importer$/, '')
|
45
|
+
files = Dir["{#{File.join(HOME_DIR, 'importer')},#{File.join(LIB_DIR, 'importer')},#{$:.join(',')}}/#{importer}.rb"]
|
46
|
+
|
47
|
+
unless (files.any? && require(files.first)) || require(importer)
|
48
|
+
raise LoadError, "Importer #{name} not found"
|
49
|
+
end
|
50
|
+
|
51
|
+
Kernel.const_get("#{importer.capitalize}Importer")
|
52
|
+
end
|
53
|
+
|
54
|
+
def run
|
55
|
+
# Bootstrap.
|
56
|
+
Ramaze::Log.loggers = []
|
57
|
+
|
58
|
+
begin
|
59
|
+
Thoth.init_thoth
|
60
|
+
rescue => e
|
61
|
+
abort("Error: #{e}")
|
62
|
+
end
|
63
|
+
|
64
|
+
# Disable model hooks.
|
65
|
+
[Comment, Media, Page, Post].each do |klass|
|
66
|
+
klass.class_eval('def before_create; end')
|
67
|
+
klass.class_eval('def before_save; end')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Confirm that the user really wants to blow away their database.
|
71
|
+
puts "WARNING: Your existing Thoth database will be completely erased to make way"
|
72
|
+
puts "for the imported content. Are you sure you want to continue? (y/n) "
|
73
|
+
print "> "
|
74
|
+
|
75
|
+
exit unless STDIN.gets.strip =~ /^y(?:es)?/i
|
76
|
+
puts
|
77
|
+
|
78
|
+
trait[:before].call if trait[:before]
|
79
|
+
|
80
|
+
if trait[:pages]
|
81
|
+
puts 'Importing pages...'
|
82
|
+
|
83
|
+
Thoth.db.transaction do
|
84
|
+
Page.delete
|
85
|
+
trait[:pages].call
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if trait[:posts]
|
90
|
+
puts 'Importing blog posts...'
|
91
|
+
|
92
|
+
Thoth.db.transaction do
|
93
|
+
Post.delete
|
94
|
+
trait[:posts].call
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
if trait[:tags]
|
99
|
+
puts 'Importing tags...'
|
100
|
+
|
101
|
+
Thoth.db.transaction do
|
102
|
+
Tag.delete
|
103
|
+
TagsPostsMap.delete
|
104
|
+
trait[:tags].call
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if trait[:comments]
|
109
|
+
puts 'Importing comments...'
|
110
|
+
|
111
|
+
Thoth.db.transaction do
|
112
|
+
Comment.delete
|
113
|
+
trait[:comments].call
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
if trait[:media]
|
118
|
+
puts 'Importing media...'
|
119
|
+
|
120
|
+
Thoth.db.transaction do
|
121
|
+
Media.delete
|
122
|
+
trait[:media].call
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
trait[:after].call if trait[:after]
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<title><%== @title ? @title : Thoth::Config.site['name'] %></title>
|
6
|
+
|
7
|
+
<%= Thoth::MainController.render_view(:css) %>
|
8
|
+
|
9
|
+
<link rel="alternate" type="application/atom+xml"
|
10
|
+
href="<%= Thoth::MainController.r(:atom) %>" title="Posts (Atom)" />
|
11
|
+
<link rel="alternate" type="application/rss+xml"
|
12
|
+
href="<%= Thoth::MainController.r(:rss) %>" title="Posts (RSS)" />
|
13
|
+
<% if @feeds; @feeds.each do |feed| %>
|
14
|
+
<link rel="alternate" type="<%== feed[:type] %>"
|
15
|
+
href="<%== feed[:href] %>" title="<%== feed[:title] %>" />
|
16
|
+
<% end; end %>
|
17
|
+
|
18
|
+
<link rel="home" href="<%== Thoth::Config.site['url'] %>" />
|
19
|
+
|
20
|
+
<% if @pager %>
|
21
|
+
<% if @pager.prev_url %>
|
22
|
+
<link id="prev_url" rel="prev" href="<%== @pager.prev_url %>" />
|
23
|
+
<% end %>
|
24
|
+
<% if @pager.next_url %>
|
25
|
+
<link id="next_url" rel="next" href="<%== @pager.next_url %>" />
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div id="doc">
|
31
|
+
<%= Thoth::MainController.render_view(:header) %>
|
32
|
+
|
33
|
+
<div id="bd">
|
34
|
+
<%= Thoth::MainController.render_view(:sidebar) %>
|
35
|
+
|
36
|
+
<div id="main">
|
37
|
+
<%= flashbox('<div class="flash %key">%value</div>') %>
|
38
|
+
<%= @content %>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<%= Thoth::MainController.render_view(:footer) %>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<%= Thoth::MainController.render_view(:js) %>
|
46
|
+
</body>
|
47
|
+
</html>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
require 'cssmin'
|
30
|
+
require 'jsmin'
|
31
|
+
|
32
|
+
module Thoth
|
33
|
+
|
34
|
+
# Rack middleware that intercepts and minifies CSS and JavaScript responses,
|
35
|
+
# caching the minified content to speed up future requests.
|
36
|
+
class Minify
|
37
|
+
|
38
|
+
MINIFIERS = {
|
39
|
+
'application/javascript' => JSMin,
|
40
|
+
'text/css' => CSSMin,
|
41
|
+
'text/javascript' => JSMin
|
42
|
+
}
|
43
|
+
|
44
|
+
EXCLUDE = [
|
45
|
+
/-min\.(?:css|js)$/i
|
46
|
+
]
|
47
|
+
|
48
|
+
def initialize(app)
|
49
|
+
@app = app
|
50
|
+
|
51
|
+
Ramaze::Cache.add(:minify) unless Ramaze::Cache.respond_to?(:minify)
|
52
|
+
@cache = Ramaze::Cache.minify
|
53
|
+
end
|
54
|
+
|
55
|
+
def call(env)
|
56
|
+
@status, @headers, @body = @app.call(env)
|
57
|
+
|
58
|
+
unless @status == 200 && @minifier = MINIFIERS[@headers['Content-Type']]
|
59
|
+
return [@status, @headers, @body]
|
60
|
+
end
|
61
|
+
|
62
|
+
@path = Rack::Utils.unescape(env['PATH_INFO'])
|
63
|
+
|
64
|
+
EXCLUDE.each {|ex| return [@status, @headers, @body] if @path =~ ex }
|
65
|
+
|
66
|
+
@headers.delete('Content-Length')
|
67
|
+
@headers['Cache-Control'] = 'max-age=3600,public'
|
68
|
+
|
69
|
+
[@status, @headers, self]
|
70
|
+
end
|
71
|
+
|
72
|
+
def each
|
73
|
+
content = ''
|
74
|
+
|
75
|
+
@body.each {|part| content << part.to_s }
|
76
|
+
@body = @cache["minify_#{@path}"] ||= @minifier.minify(content)
|
77
|
+
|
78
|
+
yield @body
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class CreateSchema < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_table :comments, :media, :pages, :posts, :tags, :tags_posts_map
|
32
|
+
end
|
33
|
+
|
34
|
+
def up
|
35
|
+
unless table_exists?(:comments)
|
36
|
+
create_table :comments do
|
37
|
+
primary_key :id
|
38
|
+
|
39
|
+
varchar :author, :null => false
|
40
|
+
varchar :author_url
|
41
|
+
varchar :title, :null => false
|
42
|
+
text :body, :default => ''
|
43
|
+
text :body_rendered, :default => ''
|
44
|
+
varchar :ip
|
45
|
+
datetime :created_at, :null => false
|
46
|
+
datetime :updated_at, :null => false
|
47
|
+
|
48
|
+
foreign_key :post_id, :table => :posts
|
49
|
+
index :post_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
unless table_exists?(:media)
|
54
|
+
create_table :media do
|
55
|
+
primary_key :id
|
56
|
+
|
57
|
+
varchar :filename, :null => false, :unique => true
|
58
|
+
varchar :mimetype, :null => false
|
59
|
+
datetime :created_at, :null => false
|
60
|
+
datetime :updated_at, :null => false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
unless table_exists?(:pages)
|
65
|
+
create_table :pages do
|
66
|
+
primary_key :id
|
67
|
+
|
68
|
+
varchar :title, :null => false, :unique => true
|
69
|
+
varchar :name, :null => false, :unique => true
|
70
|
+
text :body, :null => false
|
71
|
+
text :body_rendered, :null => false
|
72
|
+
datetime :created_at, :null => false
|
73
|
+
datetime :updated_at, :null => false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
unless table_exists?(:posts)
|
78
|
+
create_table :posts do
|
79
|
+
primary_key :id
|
80
|
+
|
81
|
+
varchar :title, :null => false, :unique => true
|
82
|
+
varchar :name, :null => false, :unique => true
|
83
|
+
text :body, :null => false
|
84
|
+
text :body_rendered, :null => false
|
85
|
+
datetime :created_at, :null => false
|
86
|
+
datetime :updated_at, :null => false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
unless table_exists?(:tags)
|
91
|
+
create_table :tags do
|
92
|
+
primary_key :id
|
93
|
+
varchar :name, :null => false, :unique => true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
unless table_exists?(:tags_posts_map)
|
98
|
+
create_table :tags_posts_map do
|
99
|
+
primary_key :id
|
100
|
+
|
101
|
+
foreign_key :post_id, :table => :posts
|
102
|
+
foreign_key :tag_id, :table => :tags
|
103
|
+
|
104
|
+
unique([:post_id, :tag_id])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class AddMediaSize < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_column(:media, :size)
|
32
|
+
end
|
33
|
+
|
34
|
+
def up
|
35
|
+
add_column(:media, :size, :integer, :null => false, :default => 0)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class AddPostDraft < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_column(:posts, :is_draft)
|
32
|
+
end
|
33
|
+
|
34
|
+
def up
|
35
|
+
add_column(:posts, :is_draft, :boolean, :null => false, :default => false)
|
36
|
+
add_index(:posts, :is_draft)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class AddCommentEmail < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_column(:comments, :author_email)
|
32
|
+
end
|
33
|
+
|
34
|
+
def up
|
35
|
+
add_column(:comments, :author_email, :varchar)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class AddPagePosition < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_column(:pages, :position)
|
32
|
+
end
|
33
|
+
|
34
|
+
def up
|
35
|
+
add_column(:pages, :position, :integer, :null => false, :default => 1)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010 Ryan Grove <ryan@wonko.com>
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
# * Neither the name of this project nor the names of its contributors may be
|
14
|
+
# used to endorse or promote products derived from this software without
|
15
|
+
# specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
18
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
21
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
23
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
25
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
class AddCommentCloseDelete < Sequel::Migration
|
30
|
+
def down
|
31
|
+
drop_index(:comments, :deleted)
|
32
|
+
drop_column(:comments, :deleted)
|
33
|
+
|
34
|
+
drop_column(:posts, :allow_comments)
|
35
|
+
end
|
36
|
+
|
37
|
+
def up
|
38
|
+
add_column(:comments, :deleted, FalseClass, :default => false, :null => false)
|
39
|
+
add_index(:comments, :deleted)
|
40
|
+
|
41
|
+
add_column(:posts, :allow_comments, TrueClass, :default => true, :null => false)
|
42
|
+
end
|
43
|
+
end
|