schreihals 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +1 -1
  2. data/.rspec +1 -0
  3. data/.travis.yml +9 -0
  4. data/.watchr +6 -5
  5. data/LICENSE +2 -2
  6. data/README.md +2 -54
  7. data/Rakefile +4 -9
  8. data/lib/schreihals.rb +10 -9
  9. data/lib/schreihals/actions/admin.rb +49 -0
  10. data/lib/schreihals/actions/auth.rb +29 -0
  11. data/lib/schreihals/actions/blog.rb +68 -0
  12. data/lib/schreihals/app.rb +15 -43
  13. data/lib/schreihals/cli.rb +0 -14
  14. data/lib/schreihals/helpers.rb +38 -5
  15. data/lib/schreihals/post.rb +126 -44
  16. data/lib/schreihals/rake.rb +21 -0
  17. data/lib/schreihals/version.rb +1 -1
  18. data/lib/templates/new_blog/Gemfile +17 -1
  19. data/lib/templates/new_blog/Rakefile +2 -0
  20. data/lib/templates/new_blog/app.rb.tt +28 -0
  21. data/lib/templates/new_blog/config.ru.tt +2 -14
  22. data/{example/public/media → lib/templates/new_blog/public}/.gitkeep +0 -0
  23. data/lib/views/admin/admin.haml +12 -0
  24. data/lib/views/admin/edit.haml +3 -0
  25. data/lib/views/admin/new.haml +3 -0
  26. data/lib/views/atom.haml +12 -10
  27. data/lib/views/index.haml +3 -0
  28. data/lib/views/layout.haml +4 -3
  29. data/lib/views/partials/_admin_post_list.haml +11 -0
  30. data/lib/views/partials/_form_field.haml +27 -0
  31. data/lib/views/partials/_post.haml +16 -12
  32. data/lib/views/partials/_post_form.haml +12 -0
  33. data/lib/views/schreihals.scss +61 -25
  34. data/schreihals.gemspec +27 -11
  35. data/spec/app_spec.rb +56 -0
  36. data/spec/factories.rb +15 -0
  37. data/spec/post_spec.rb +60 -0
  38. data/spec/spec_helper.rb +35 -0
  39. data/{test → test.old}/app_test.rb +0 -0
  40. data/{test → test.old}/files/simple_document.md +0 -0
  41. data/test.old/post_test.rb +62 -0
  42. data/{test → test.old}/posts/2011-12-23-first-post.md +0 -0
  43. data/{test → test.old}/posts/2011-12-24-second-post.md +0 -0
  44. data/{test → test.old}/posts/static-page.md +0 -0
  45. data/{test → test.old}/test_helper.rb +0 -0
  46. metadata +158 -87
  47. data/example/Gemfile +0 -5
  48. data/example/config.ru +0 -8
  49. data/example/posts/2010-06-17-pythton-is-great.md +0 -9
  50. data/example/posts/2011-12-22-ruby-is-great.md +0 -16
  51. data/lib/schreihals/actions.rb +0 -45
  52. data/lib/schreihals/document.rb +0 -52
  53. data/lib/templates/first-post.md.tt +0 -1
  54. data/lib/templates/new-post.md.tt +0 -13
  55. data/lib/templates/new_blog/posts/.gitkeep +0 -0
  56. data/lib/templates/new_blog/public/media/.gitkeep +0 -0
  57. data/test/document_test.rb +0 -41
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # In a real-world schreihals blog, remove the :path option, obviously.
4
- #
5
- gem 'schreihals', :path => '../'
@@ -1,8 +0,0 @@
1
- require 'schreihals'
2
-
3
- class MyBlog < Schreihals::App
4
- set :blog_title, "The Blog of AWESOME"
5
- set :author_name, "Mr. Schreihals"
6
- end
7
-
8
- run MyBlog
@@ -1,9 +0,0 @@
1
- ---
2
- id: 1
3
- title: Python is great
4
- tags: [programming, python]
5
- slug: python-is-great
6
- status: published
7
- ---
8
-
9
- This is *just a test*.
@@ -1,16 +0,0 @@
1
- ---
2
- id: 1
3
- title: Ruby is great
4
- tags: [programming, ruby]
5
- slug: ruby-is-great
6
- status: published
7
- ---
8
-
9
- Bacon ipsum dolor sit amet shank sirloin pork belly, filet mignon ground round hamburger capicola brisket corned beef short ribs salami venison pork drumstick prosciutto. Strip steak ground round ribeye, jerky pig meatball fatback beef ribs brisket kielbasa. Tail biltong sausage, brisket pork belly beef rump fatback shoulder kielbasa beef ribs. Capicola prosciutto swine, t-bone turkey spare ribs biltong venison fatback beef ribs brisket strip steak pork meatball andouille. Meatball turducken salami pastrami leberkäse capicola chuck ball tip bacon kielbasa shoulder cow, pork chop pork belly. Prosciutto chuck meatball, hamburger andouille ribeye rump drumstick ham hock corned beef short loin. Short loin shankle strip steak kielbasa.
10
-
11
- * This is what unordered lists look like.
12
- * I hope they look nice.
13
- * Lorem to the ipsum.
14
-
15
- So, yeah, Ruby is great. But this is really just a demo
16
- post to see how the Markdown is being formatted.
@@ -1,45 +0,0 @@
1
- module Schreihals
2
- module Actions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- before do
7
- refresh_documents! if refresh_documents_now?
8
- cache_control :public, :must_revalidate, :max_age => 60
9
- end
10
-
11
- get '/' do
12
- @posts = Post.latest(published_only: production?)
13
-
14
- @show_description = true
15
- haml :index
16
- end
17
-
18
- get '/blog.css' do
19
- scss :blog
20
- end
21
-
22
- get '/atom.xml' do
23
- @posts = Post.latest(published_only: production?)
24
-
25
- xml = haml :atom, :layout => false
26
-
27
- doc = Nokogiri::XML(xml)
28
- doc.css("content img").each do |node|
29
- node['src'] = absolutionize(node['src'])
30
- end
31
-
32
- content_type 'application/xml+atom'
33
- doc.to_xml
34
- end
35
-
36
- get '/:year/:month/:day/:slug/?' do |year, month, day, slug|
37
- render_page(slug)
38
- end
39
-
40
- get '/:slug/?' do |slug|
41
- render_page(slug)
42
- end
43
- end
44
- end
45
- end
@@ -1,52 +0,0 @@
1
- require 'tilt'
2
-
3
- module Schreihals
4
- class Document
5
- cattr_accessor :documents
6
- @@documents = []
7
-
8
- attr_accessor :attributes
9
-
10
- def initialize(attrs = {})
11
- @attributes = attrs
12
- @@documents << self
13
- end
14
-
15
- def file_extension
16
- File.extname(file_name).sub(/^\./, '')
17
- end
18
-
19
- def file_name_without_extension
20
- File.basename(file_name, '.'+file_extension)
21
- end
22
-
23
- def method_missing(name, *args)
24
- attributes.has_key?(name.to_s) ? attributes[name.to_s] : super
25
- end
26
-
27
- def to_html
28
- Tilt.new(file_extension) { body }.render
29
- end
30
-
31
- class << self
32
- def from_string(s, attrs = {})
33
- frontmatter, body = split_original_document(s)
34
- new(Psych.load(frontmatter).
35
- merge('body' => body.strip).
36
- merge(attrs))
37
- end
38
-
39
- def from_file(name)
40
- from_string(open(name).read, 'file_name' => File.basename(name))
41
- end
42
-
43
- def load_from_directory(dir)
44
- Dir[File.join(dir, "*")].collect { |f| from_file f }
45
- end
46
-
47
- def split_original_document(s)
48
- s =~ /.*(---\s*\n.*)\n---\s*\n(.*)/m ? [$1, $2] : [nil, s]
49
- end
50
- end
51
- end
52
- end
@@ -1 +0,0 @@
1
- first_post
@@ -1,13 +0,0 @@
1
- ---
2
- title: <%= @title %>
3
- summary:
4
- link:
5
-
6
- # More options:
7
- #
8
- # status: draft
9
- # read_more:
10
- # disqus: false
11
- ---
12
-
13
- <%= @text %>
File without changes
@@ -1,41 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- context Schreihals::Document do
4
- helper(:test_document_directory) { File.expand_path('../files/', __FILE__) }
5
- helper(:test_document_filename) { File.join(test_document_directory, 'simple_document.md') }
6
- helper(:test_document_contents) { open(test_document_filename).read }
7
-
8
- setup { Schreihals::Document }
9
-
10
- context "#from_string" do
11
- setup { topic.from_string open(test_document_filename).read }
12
-
13
- asserts(:class).equals Schreihals::Document
14
- asserts(:body).equals "This is the body."
15
- asserts(:title).equals "This is the title"
16
- asserts("automatically converts dates into Date objects") { topic.date.kind_of? Date }
17
- asserts("automatically converts datetimes into Time objects") { topic.datetime.kind_of? Time }
18
- end
19
-
20
- asserts "#from_file should call #from_string with the contents of the file" do
21
- mock.proxy(topic).from_string(test_document_contents, { 'file_name' => 'simple_document.md' })
22
- topic.from_file(test_document_filename)
23
- end.kind_of?(Schreihals::Document)
24
-
25
- context "#from_file" do
26
- setup { topic.from_file(test_document_filename) }
27
-
28
- asserts(:file_name).equals "simple_document.md"
29
- asserts(:file_name_without_extension).equals "simple_document"
30
- asserts(:file_extension).equals "md"
31
- end
32
-
33
- context "#load_from_directory" do
34
- should "call #from_file for each file contained in the directory" do
35
- Dir[File.join(test_document_directory, "*")].each do |f|
36
- mock.proxy(topic).from_file(f)
37
- end
38
- topic.load_from_directory(test_document_directory)
39
- end.kind_of?(Array)
40
- end
41
- end