serious 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,5 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+
23
+ test/tmp/*
data/README.rdoc CHANGED
@@ -59,6 +59,7 @@ The directory basic directory structure of your Serious site would be something
59
59
  - articles/2010-02-14-will-you-be-my-valentine.txt
60
60
  - config.ru
61
61
  - .gems
62
+ - Rakefile
62
63
 
63
64
  The config.ru is pretty straight-forward if you want to stick to the defaults:
64
65
 
@@ -70,12 +71,16 @@ The config.ru is pretty straight-forward if you want to stick to the defaults:
70
71
 
71
72
  The .gems file if you want to host on heroku:
72
73
 
73
- stupid_formatter
74
74
  serious
75
75
 
76
76
  Note that sinatra is not included in the gemfile since heroku has it installed by default, but serious
77
77
  will install it as a gem dependency on other systems as well.
78
78
 
79
+ The Rakefile, which is obviously totally optional but highly recommended.
80
+
81
+ require 'serious'
82
+ require 'serious/tasks'
83
+
79
84
  == Creating heroku app manually
80
85
 
81
86
  Assuming you've got the heroku gem installed and set up and you've set up git for your blog with
@@ -86,10 +91,12 @@ Assuming you've got the heroku gem installed and set up and you've set up git fo
86
91
 
87
92
  Point your browser to the url, and bang, you're ready!
88
93
 
89
- == Running with thin
94
+ == Running locally
90
95
 
91
- You might also want to test your blog locally or host it with thin.
92
- Use thin (<code>sudo gem install thin</code>) with:
96
+ You might also want to test your blog locally. Use the <code>rake server</code> command inside
97
+ your site's directory.
98
+
99
+ You can also use thin (<code>sudo gem install thin</code>) with:
93
100
 
94
101
  thin -R config.ru start
95
102
 
@@ -101,6 +108,26 @@ The whole archives can be accessed at <code>/archives</code>. Archives by year,
101
108
  are available at <code>/2009</code> (all of 2009), <code>/2009/05</code> (May 2009),
102
109
  <code>/2009/05/15</code> (May 15th 2009).
103
110
 
111
+ == Rake tasks
112
+
113
+ If you've set up the Rakefile in your site's main directory like mentioned above (this happens
114
+ automatically when generating with the <code>serious</code> executable), you have the following
115
+ tasks available:
116
+
117
+ rake article:create # Creates a new article
118
+ rake article:validate # Validates all articles, making sure they can be processed correctly
119
+ rake server # Runs a server hosting your site on localhost:3000 using rackup
120
+
121
+ The default is article:create, so to create a new article, just type <code>rake</code>,
122
+ specify your title and optionally a date and you're ready to go!
123
+
124
+ It's highly recommended that you run the <code>article:validate</code> task before publishing,
125
+ since it will make sure everything gets processed correctly.
126
+
127
+ Please be aware that you have to run the Rake tasks from the top level directory (where your
128
+ <code>config.ru</code> file resides) since the config.ru file will be loaded to reflect your
129
+ settings.
130
+
104
131
  == Comments with disqus
105
132
 
106
133
  You can activate comments for articles very easily with disqus (http://disqus.com) by setting
@@ -267,7 +294,6 @@ to learn how to add your own formatters or erb helpers.
267
294
  * make caching better
268
295
  * make it possible to host in subdirectories
269
296
  * valid xhtml in demo setup
270
- * rake tasks for generating new posts and validating existing
271
297
  * allow for choice between erb/haml templates
272
298
 
273
299
  == Note on Patches/Pull Requests
@@ -280,6 +306,12 @@ to learn how to add your own formatters or erb helpers.
280
306
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
281
307
  * Send me a pull request. Bonus points for topic branches.
282
308
 
309
+ == Font credits
310
+
311
+ The fonts supplied with the gem and used by the default theme are Yanone Kaffeesatz
312
+ (http://www.fonts.info/info/en_yanone-kaffeesatz.htm) and Vollkorn (http://friedrichalthausen.de/2006/01/01/vollkorn/),
313
+ licensed under Creative Commons Attribution 2.0 Generic (http://creativecommons.org/licenses/by/2.0/).
314
+
283
315
  == Thanks
284
316
 
285
317
  Alexis Sellier for toto, the main inspiration for this gem
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/bin/serious CHANGED
@@ -31,6 +31,7 @@ end
31
31
 
32
32
  require 'fileutils'
33
33
  puts "Creating directory #{DIRNAME}"
34
+ ORIGINAL_DIR = Dir.getwd
34
35
  FileUtils.mkdir_p(File.join(DIRNAME, 'articles'))
35
36
  Dir.chdir(DIRNAME)
36
37
 
@@ -84,10 +85,15 @@ end
84
85
 
85
86
  puts "Creating .gems file"
86
87
  File.open(".gems", "w+") do |gems|
87
- gems.puts "stupid_formatter"
88
88
  gems.puts "serious --version '>= #{File.read(File.join(GEM_ROOT, 'VERSION')).strip.chomp}'"
89
89
  end
90
90
 
91
+ puts "Creating Rakefile"
92
+ File.open('Rakefile', "w+") do |rake|
93
+ rake.puts "require 'serious'"
94
+ rake.puts "require 'serious/tasks'"
95
+ end
96
+
91
97
  if git?
92
98
  puts "Creating git repo"
93
99
  system "git init"
@@ -115,3 +121,5 @@ if heroku?
115
121
  end
116
122
 
117
123
  puts "Done!"
124
+
125
+ Dir.chdir(ORIGINAL_DIR)
data/lib/ruby_ext.rb CHANGED
@@ -27,3 +27,9 @@ class Fixnum
27
27
  end
28
28
  end
29
29
  end
30
+
31
+ class String
32
+ def slugize
33
+ self.downcase.gsub(/[^a-z0-9\-]/, '-').squeeze('-').gsub(/^\-/, '').gsub(/\-$/, '')
34
+ end
35
+ end
@@ -2,6 +2,10 @@
2
2
  # Backend for file-system based articles
3
3
  #
4
4
  class Serious::Article
5
+ # Exception for invalid filenames
6
+ class InvalidFilename < StandardError
7
+ end
8
+
5
9
  class << self
6
10
  #
7
11
  # Returns all articles. Can be drilled down by (optional) :limit and :offset options
@@ -86,6 +90,35 @@ class Serious::Article
86
90
  false
87
91
  end
88
92
 
93
+ # Collection of validation errors
94
+ def errors
95
+ @errors || valid?
96
+ end
97
+
98
+ #
99
+ # Loads the article and makes sure it can be loaded, formatted etc..
100
+ # Error messages can be read through errors array
101
+ #
102
+ def valid?
103
+ @errors = []
104
+ errors << "No title given" unless title.kind_of?(String) and title.length > 0
105
+ errors << "No author given" unless author.kind_of?(String) and author.length > 0
106
+
107
+ begin
108
+ summary.formatted
109
+ rescue => err
110
+ errors << "Failed to format summary"
111
+ end
112
+
113
+ begin
114
+ body.formatted
115
+ rescue => err
116
+ errors << "Failed to format body"
117
+ end
118
+ ensure
119
+ return errors.length == 0
120
+ end
121
+
89
122
  private
90
123
 
91
124
  # Will extract the date and permalink from the filename.
@@ -93,6 +126,8 @@ class Serious::Article
93
126
  match = File.basename(path).match(/(\d{4})-(\d{1,2})-(\d{1,2})-([^\.]+)/)
94
127
  @date = Date.new(match[1].to_i, match[2].to_i, match[3].to_i)
95
128
  @permalink = match[4]
129
+ rescue NoMethodError => err
130
+ raise InvalidFilename, "Failed to extract date or permalink from #{File.basename(path)}"
96
131
  end
97
132
 
98
133
  #
@@ -100,7 +135,7 @@ class Serious::Article
100
135
  # the content in @content
101
136
  #
102
137
  def load!
103
- return [@yaml, @content] if @yaml and @content
138
+ return true if @yaml and @content
104
139
  yaml, @content = File.read(path).split(/\n\n/, 2)
105
140
  @yaml = YAML.load(yaml)
106
141
  end
@@ -0,0 +1,64 @@
1
+ # Swallow the actual run method from config.ru
2
+ def run(*args)
3
+ end
4
+
5
+ begin
6
+ config = File.read('config.ru')
7
+ eval config
8
+ rescue Errno::ENOENT => err
9
+ puts "ERROR: Failed to load your config from config.ru!"
10
+ exit 1
11
+ end
12
+
13
+ def ask(q)
14
+ print "#{q} "
15
+ STDIN.gets.strip.chomp
16
+ end
17
+
18
+ namespace :article do
19
+ desc "Validates all articles, making sure they can be processed correctly"
20
+ task :validate do
21
+ Serious::Article.all.each do |article|
22
+ unless article.valid?
23
+ puts "", "Article #{File.basename(article.path)} is not valid!"
24
+ puts " Errors: #{article.errors.sort.join(", ")}"
25
+ end
26
+ end
27
+
28
+ puts
29
+ puts "Validated #{Serious::Article.all.length} article(s)!"
30
+ end
31
+
32
+ desc "Creates a new article"
33
+ task :create do
34
+ title = ask('Title?')
35
+ if date = ask("Date (defaults to #{Date.today})? ") and date.length > 0
36
+ begin
37
+ article_date = Date.new(*date.split('-').map(&:to_i))
38
+ rescue => err
39
+ puts "Whoops, failed to process the date! The format must be #{Date.today}, you gave #{date}"
40
+ raise err
41
+ exit 1
42
+ end
43
+ else
44
+ article_date = Date.today
45
+ end
46
+
47
+ filename = "#{article_date}-#{title.slugize}.txt"
48
+ File.open(File.join(Serious.articles, filename), "w") do |article|
49
+ article.puts "title: #{title}", ""
50
+ article.puts "Summary here", "~", "Body here"
51
+ end
52
+
53
+ puts "Created article #{filename}!"
54
+ end
55
+ end
56
+
57
+ desc "Runs a server hosting your site on localhost:3000 using rackup"
58
+ task :server do
59
+ puts "Server listening on http://localhost:3000"
60
+ system "rackup -p 3000 -o localhost"
61
+ puts "Bye!"
62
+ end
63
+
64
+ task :default => :"article:create"
@@ -1,17 +1,28 @@
1
1
  body {
2
2
  margin: 0 auto;
3
- font-family: 'Baskerville', Georgia, Times, serif;
3
+ font-family: 'Junction', 'Baskerville', Georgia, Times, serif;
4
4
  font-size: 20px;
5
5
  line-height: 30px;
6
6
  width: 800px;
7
7
  }
8
8
 
9
+ @font-face {
10
+ font-family: Vollkorn;
11
+ src: url('/fonts/vollkorn.otf') format("opentype");
12
+ }
13
+
14
+ @font-face {
15
+ font-family: 'Yanone Kaffeesatz Thin';
16
+ src: url('/fonts/YanoneKaffeesatz-Thin.otf') format("opentype");
17
+ }
18
+
19
+
9
20
  div, p {
10
- font-family: 'Baskerville', Georgia, Times, serif;
21
+ font-family: 'Vollkorn', Georgia, Times, serif;
11
22
  }
12
23
 
13
24
  h1, h2, h3, h4 {
14
- font-family: "Helvetica", "Arial", "Verdana", sans-serif;
25
+ font-family: 'Yanone Kaffeesatz Thin', "Helvetica", "Arial", "Verdana", sans-serif;
15
26
  padding: 0;
16
27
  margin: 0;
17
28
  }
@@ -31,14 +42,14 @@ h1, h2, h3, h4 {
31
42
  }
32
43
 
33
44
  #header {
34
- margin: 0px 0px 25px 0px;
35
- padding: 25px;
45
+ margin: 0px 0px 60px 0px;
46
+ padding: 30px;
36
47
  text-align: center;
37
- border-bottom: 3px solid #BE2805;
48
+ border-bottom: 2px solid #BE2805;
38
49
  }
39
50
 
40
51
  #header h1 {
41
- font-family: 'Baskerville', Georgia, Times, serif;
52
+ font-family: 'Yanone Kaffeesatz Thin', "Helvetica", "Arial", "Verdana", sans-serif;
42
53
  font-size: 28px;
43
54
  }
44
55
 
@@ -94,15 +105,25 @@ h1, h2, h3, h4 {
94
105
  padding-top: 25px;
95
106
  }
96
107
 
108
+ #disqus_thread h3 {
109
+ padding: 15px 0px;
110
+ font-size: 20px;
111
+ }
97
112
 
98
113
  #footer {
99
114
  margin-top: 50px;
100
115
  color: #666;
101
116
  text-align: right;
102
117
  font-size: 14px;
118
+ line-height: 18px;
103
119
  }
104
120
 
105
121
  #footer a {
106
122
  text-decoration: none;
107
123
  color: black;
108
124
  }
125
+
126
+ #footer p {
127
+ margin: 0;
128
+ padding: 0;
129
+ }
Binary file
@@ -15,7 +15,14 @@
15
15
  </div>
16
16
 
17
17
  <div id="footer">
18
- This blog is <a href="http://github.com/colszowka/serious">serious</a>
18
+ <p>
19
+ This blog is <a href="http://github.com/colszowka/serious">serious</a>.
20
+ </p>
21
+ <p>
22
+ Fonts used are <a href="http://www.fonts.info/info/en_yanone-kaffeesatz.htm">Yanone Kaffeesatz</a> and
23
+ <a href="http://friedrichalthausen.de/2006/01/01/vollkorn/">Vollkorn</a>, licensed under
24
+ <a href="http://creativecommons.org/licenses/by/2.0/">CC 2.0</a>.
25
+ </p>
19
26
  </div>
20
27
 
21
28
  <%= render_partial :google_analytics if Serious.google_analytics %>
data/serious.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{serious}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christoph Olszowka"]
@@ -29,8 +29,11 @@ Gem::Specification.new do |s|
29
29
  "lib/ruby_ext.rb",
30
30
  "lib/serious.rb",
31
31
  "lib/serious/article.rb",
32
+ "lib/serious/tasks.rb",
32
33
  "lib/site/public/css/coderay.css",
33
34
  "lib/site/public/css/serious.css",
35
+ "lib/site/public/fonts/YanoneKaffeesatz-Thin.otf",
36
+ "lib/site/public/fonts/vollkorn.otf",
34
37
  "lib/site/views/404.erb",
35
38
  "lib/site/views/_archives.erb",
36
39
  "lib/site/views/_article.erb",
@@ -47,6 +50,7 @@ Gem::Specification.new do |s|
47
50
  "test/articles/2009-12-24-merry-christmas.txt",
48
51
  "test/helper.rb",
49
52
  "test/test_article.rb",
53
+ "test/test_bin.rb",
50
54
  "test/test_ruby_ext.rb",
51
55
  "test/test_serious.rb"
52
56
  ]
@@ -56,7 +60,8 @@ Gem::Specification.new do |s|
56
60
  s.rubygems_version = %q{1.3.5}
57
61
  s.summary = %q{Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra}
58
62
  s.test_files = [
59
- "test/test_serious.rb",
63
+ "test/test_bin.rb",
64
+ "test/test_serious.rb",
60
65
  "test/helper.rb",
61
66
  "test/test_ruby_ext.rb",
62
67
  "test/test_article.rb"
data/test/helper.rb CHANGED
@@ -59,4 +59,60 @@ class Test::Unit::TestCase
59
59
  assert_equal "public, max-age=#{Serious.cache_timeout}", last_response.headers['Cache-Control']
60
60
  end
61
61
  end
62
+
63
+ def self.should_slugize(input, expectation)
64
+ should "return '#{expectation}' for '#{input}'.slugize" do
65
+ assert_equal expectation, input.slugize
66
+ end
67
+ end
68
+
69
+ def self.should_have_file(name, content=nil)
70
+ should "have file #{name}" do
71
+ assert File.exist?(name), "#{name} does not exist"
72
+ end
73
+
74
+ if content and not block_given?
75
+ should "have content in file #{name} match /#{content}/" do
76
+ assert_match /#{content}/, File.read(name)
77
+ end
78
+ end
79
+
80
+ yield(File.read(name)) if block_given? and File.exist?(name)
81
+ end
82
+
83
+ def self.should_have_dir(name)
84
+ should "have directory #{name}" do
85
+ assert File.directory?(name), "#{name} is not a directory"
86
+ end
87
+ end
88
+
89
+ def self.should_not_have_path(name)
90
+ should "not have directory #{name}" do
91
+ assert !File.exist?(name), "#{name} exists!"
92
+ end
93
+ end
94
+
95
+ def self.should_contain(expect, item)
96
+ should "contain #{expect}" do
97
+ assert_match /#{expect}/, item
98
+ end
99
+ end
100
+
101
+ def self.should_not_contain(expect, item)
102
+ should "not contain #{expect}" do
103
+ assert_no_match /#{expect}/, item
104
+ end
105
+ end
106
+
107
+ def self.when_running_serious_with(site_name, arguments="", cache=true)
108
+ context "when running serious #{site_name} #{arguments}" do
109
+ setup { assert @output = serious(site_name, arguments, cache) }
110
+ end
111
+ end
112
+
113
+ def self.should_print(expect)
114
+ should("print #{expect}") do
115
+ assert_match /#{expect}/, @output
116
+ end
117
+ end
62
118
  end
data/test/test_article.rb CHANGED
@@ -152,6 +152,10 @@ class TestArticle < Test::Unit::TestCase
152
152
  context "the found article" do
153
153
  setup { @article = @articles.first }
154
154
 
155
+ should "be valid" do
156
+ assert @article.valid?
157
+ end
158
+
155
159
  should "have date 2009-12-24" do
156
160
  assert_equal Date.new(2009, 12, 24), @article.date
157
161
  end
@@ -254,6 +258,9 @@ class TestArticle < Test::Unit::TestCase
254
258
  @article = Serious::Article.first('foo-bar')
255
259
  end
256
260
 
261
+ should "be valid" do
262
+ assert @article.valid?
263
+ end
257
264
  should("have title 'Foo Bar'") { assert_equal 'Foo Bar', @article.title }
258
265
  should('have summary "Baz!"') { assert_equal "Baz!\n", @article.summary }
259
266
  should('have body "Baz!"') { assert_equal "Baz!\n", @article.body }
@@ -261,4 +268,71 @@ class TestArticle < Test::Unit::TestCase
261
268
  should('have summary equal to body') { assert_equal @article.summary, @article.body}
262
269
  end
263
270
 
271
+ # ========================================================================
272
+ # Tests for validation
273
+ # ========================================================================
274
+ context "An article with invalid ERb content" do
275
+ setup do
276
+ @article = Serious::Article.new('2009-12-12-foo-bar.txt')
277
+ @article.instance_variable_set :@yaml, {"title" => "Foo Bar"}
278
+ @article.instance_variable_set :@content, "Some stupid text with <% invalid %>"
279
+ end
280
+
281
+ should("not be valid") { assert !@article.valid? }
282
+ context "after validating" do
283
+ setup { @article.valid? }
284
+
285
+ should "include 'Failed to format body' in errors" do
286
+ assert @article.errors.include?('Failed to format body'), @article.errors.inspect
287
+ end
288
+
289
+ should "include 'Failed to format summary' in errors" do
290
+ assert @article.errors.include?('Failed to format summary'), @article.errors.inspect
291
+ end
292
+ end
293
+ end
294
+
295
+ context "An article with missing title and author" do
296
+ setup do
297
+ @article = Serious::Article.new('2009-12-12-foo-bar.txt')
298
+ @article.instance_variable_set :@yaml, {"title" => nil, "author" => nil}
299
+ @article.instance_variable_set :@content, "Some stupid text"
300
+ end
301
+
302
+ should("not be valid") { assert !@article.valid? }
303
+ context "after validating" do
304
+ setup { @article.valid? }
305
+
306
+ should "include 'No title given' in errors" do
307
+ assert @article.errors.include?('No title given'), @article.errors.inspect
308
+ end
309
+
310
+ should "not include 'No author given' in errors" do
311
+ assert !@article.errors.include?('No author given'), @article.errors.inspect
312
+ end
313
+
314
+ context "after setting @author to '' and revalidating" do
315
+ setup do
316
+ @article.instance_variable_set :@author, ''
317
+ @article.valid?
318
+ end
319
+
320
+ should "include 'No title given' in errors" do
321
+ assert @article.errors.include?('No title given'), @article.errors.inspect
322
+ end
323
+
324
+ should "include 'No author given' in errors" do
325
+ assert @article.errors.include?('No author given'), @article.errors.inspect
326
+ end
327
+ end
328
+ end
329
+ end
330
+
331
+ context "An article with invalid Filename" do
332
+ should "raise Serious::Article::InvalidFilename exception on load" do
333
+ assert_raise Serious::Article::InvalidFilename do
334
+ @article = Serious::Article.new('2009-12_12-foo-bar.txt')
335
+ end
336
+ end
337
+ end
264
338
  end
data/test/test_bin.rb ADDED
@@ -0,0 +1,133 @@
1
+ require 'helper'
2
+ require 'fileutils'
3
+
4
+ #
5
+ # Tests for the serious executable
6
+ #
7
+ class TestBin < Test::Unit::TestCase
8
+ context "In tmp" do
9
+ setup do
10
+ @original_working_dir ||= Dir.getwd
11
+ Dir.chdir(File.dirname(__FILE__))
12
+ FileUtils.mkdir('tmp') if not File.exist?('tmp')
13
+ Dir.chdir('tmp')
14
+ end
15
+
16
+ when_running_serious_with '' do
17
+ should_print "Usage: serious DIRNAME"
18
+ should_print "Note: Only lowercase letters and dashes ('-') are allowed for DIRNAME"
19
+ end
20
+
21
+ when_running_serious_with '-foo-' do
22
+ should_print "Only lowercase-letters and '-' allowed in dirname!"
23
+ should_not_have_path '-foo-'
24
+ end
25
+
26
+ when_running_serious_with 'foo-123' do
27
+ should_print "Only lowercase-letters and '-' allowed in dirname!"
28
+ end
29
+
30
+ when_running_serious_with 'foo-ABC' do
31
+ should_print "Only lowercase-letters and '-' allowed in dirname!"
32
+ end
33
+
34
+ when_running_serious_with 'foo_bar' do
35
+ should_print "Only lowercase-letters and '-' allowed in dirname!"
36
+ end
37
+
38
+ when_running_serious_with 'foo' do
39
+ should_have_dir 'foo/articles'
40
+ should_have_dir 'foo/.git'
41
+ should_have_file 'foo/.gems', 'serious --version'
42
+ should_not_have_path 'foo/public'
43
+ should_not_have_path 'foo/views'
44
+
45
+ should "match git log with 'Initial commit'" do
46
+ Dir.chdir('foo')
47
+ assert_match /Initial commit/, `git log`
48
+ Dir.chdir('..')
49
+ end
50
+
51
+ should_have_file 'foo/config.ru' do |file|
52
+ should_contain "require 'serious'", file
53
+ should_contain "Serious.set :title, 'foo'", file
54
+ should_contain "Serious.set :author, 'Your Name here'", file
55
+ should_contain "Serious.set :url, 'http://foo.heroku.com'", file
56
+ should_contain "run Serious", file
57
+ end
58
+
59
+ should_have_file 'foo/Rakefile' do |file|
60
+ should_contain "require 'serious'", file
61
+ should_contain "require 'serious/tasks'", file
62
+ end
63
+
64
+ when_running_serious_with 'foo', '', false do
65
+ should("respond with 'foo exists!'") { assert_match /foo exists\!/, @output }
66
+ end
67
+ end
68
+
69
+ when_running_serious_with 'public-included', '--public' do
70
+ should_have_dir 'public-included/articles'
71
+ should_not_have_path 'public-included/views'
72
+ should_have_file 'public-included/.gems'
73
+ should_have_file 'public-included/config.ru' do |file|
74
+ should_contain "Serious.set :public, File.join(Dir.getwd, 'public')"
75
+ should_not_contain ":views"
76
+ should_not_contain ":root"
77
+ end
78
+ should_have_file "public-included/public/css/serious.css"
79
+ end
80
+
81
+ when_running_serious_with 'views-included', '--views' do
82
+ should_have_dir 'views-included/articles'
83
+ should_not_have_path 'views-included/public'
84
+ should_have_file 'views-included/.gems'
85
+ should_have_file 'views-included/config.ru' do |file|
86
+ should_contain "Serious.set :views, File.join(Dir.getwd, 'views')"
87
+ should_not_contain ":public"
88
+ should_not_contain ":root"
89
+ end
90
+ should_have_file "views-included/views/layout.erb"
91
+ end
92
+
93
+ when_running_serious_with 'views-and-public', '--views --public' do
94
+ should_have_dir 'views-and-public/articles'
95
+ should_have_file 'views-and-public/.gems'
96
+ should_have_file 'views-and-public/config.ru' do |file|
97
+ should_contain "Serious.set :root, Dir.getwd"
98
+ should_not_contain ":public"
99
+ should_not_contain ":views"
100
+ end
101
+ should_have_file "views-and-public/public/css/serious.css"
102
+ should_have_file "views-and-public/views/layout.erb"
103
+ end
104
+
105
+ when_running_serious_with 'no-git', '--no-git' do
106
+ should_not_have_path 'no-git/.git'
107
+ end
108
+
109
+ teardown do
110
+ Dir.chdir(@original_working_dir)
111
+ end
112
+ end
113
+
114
+ # Run this only once...
115
+ context "zzz" do
116
+ should "remove tmp at the end" do
117
+ FileUtils.rm_rf File.expand_path(File.join(File.dirname(__FILE__), 'tmp'))
118
+ end
119
+ end
120
+
121
+ def serious(site_name="", arguments="", cache=true)
122
+ if cache
123
+ @cache ||= {}
124
+ return @cache[site_name] if @cache[site_name]
125
+ end
126
+
127
+ executable = File.expand_path(File.join(File.dirname(__FILE__), '..', '../../bin/serious'))
128
+ output = `#{executable} #{site_name} #{arguments}`
129
+ @cache[site_name] = output if cache
130
+ output
131
+ end
132
+
133
+ end
@@ -66,4 +66,14 @@ class TestRubyExt < Test::Unit::TestCase
66
66
  should("return '4th' for 4.ordinal") { assert_equal '4th', 4.ordinal}
67
67
  should("return '31st' for 31.ordinal") { assert_equal '31st', 31.ordinal}
68
68
 
69
+ # ========================================================================
70
+ # Tests for slugize
71
+ # ========================================================================
72
+ should_slugize 'Foo Bar Baz', 'foo-bar-baz'
73
+ should_slugize ' Foo Bar_Baz ', 'foo-bar-baz'
74
+ should_slugize 'A Crazy Title with: Special Chars!', 'a-crazy-title-with-special-chars'
75
+ should_slugize 'We have 0123 numbers in here', 'we-have-0123-numbers-in-here'
76
+ should_slugize 'and we have !? more special char$', 'and-we-have-more-special-char'
77
+ should_slugize 'should--squeeze$', 'should-squeeze'
78
+
69
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
@@ -92,8 +92,11 @@ files:
92
92
  - lib/ruby_ext.rb
93
93
  - lib/serious.rb
94
94
  - lib/serious/article.rb
95
+ - lib/serious/tasks.rb
95
96
  - lib/site/public/css/coderay.css
96
97
  - lib/site/public/css/serious.css
98
+ - lib/site/public/fonts/YanoneKaffeesatz-Thin.otf
99
+ - lib/site/public/fonts/vollkorn.otf
97
100
  - lib/site/views/404.erb
98
101
  - lib/site/views/_archives.erb
99
102
  - lib/site/views/_article.erb
@@ -110,6 +113,7 @@ files:
110
113
  - test/articles/2009-12-24-merry-christmas.txt
111
114
  - test/helper.rb
112
115
  - test/test_article.rb
116
+ - test/test_bin.rb
113
117
  - test/test_ruby_ext.rb
114
118
  - test/test_serious.rb
115
119
  has_rdoc: true
@@ -141,6 +145,7 @@ signing_key:
141
145
  specification_version: 3
142
146
  summary: Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra
143
147
  test_files:
148
+ - test/test_bin.rb
144
149
  - test/test_serious.rb
145
150
  - test/helper.rb
146
151
  - test/test_ruby_ext.rb