schreihals 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/.watchr +6 -5
- data/LICENSE +2 -2
- data/README.md +2 -54
- data/Rakefile +4 -9
- data/lib/schreihals.rb +10 -9
- data/lib/schreihals/actions/admin.rb +49 -0
- data/lib/schreihals/actions/auth.rb +29 -0
- data/lib/schreihals/actions/blog.rb +68 -0
- data/lib/schreihals/app.rb +15 -43
- data/lib/schreihals/cli.rb +0 -14
- data/lib/schreihals/helpers.rb +38 -5
- data/lib/schreihals/post.rb +126 -44
- data/lib/schreihals/rake.rb +21 -0
- data/lib/schreihals/version.rb +1 -1
- data/lib/templates/new_blog/Gemfile +17 -1
- data/lib/templates/new_blog/Rakefile +2 -0
- data/lib/templates/new_blog/app.rb.tt +28 -0
- data/lib/templates/new_blog/config.ru.tt +2 -14
- data/{example/public/media → lib/templates/new_blog/public}/.gitkeep +0 -0
- data/lib/views/admin/admin.haml +12 -0
- data/lib/views/admin/edit.haml +3 -0
- data/lib/views/admin/new.haml +3 -0
- data/lib/views/atom.haml +12 -10
- data/lib/views/index.haml +3 -0
- data/lib/views/layout.haml +4 -3
- data/lib/views/partials/_admin_post_list.haml +11 -0
- data/lib/views/partials/_form_field.haml +27 -0
- data/lib/views/partials/_post.haml +16 -12
- data/lib/views/partials/_post_form.haml +12 -0
- data/lib/views/schreihals.scss +61 -25
- data/schreihals.gemspec +27 -11
- data/spec/app_spec.rb +56 -0
- data/spec/factories.rb +15 -0
- data/spec/post_spec.rb +60 -0
- data/spec/spec_helper.rb +35 -0
- data/{test → test.old}/app_test.rb +0 -0
- data/{test → test.old}/files/simple_document.md +0 -0
- data/test.old/post_test.rb +62 -0
- data/{test → test.old}/posts/2011-12-23-first-post.md +0 -0
- data/{test → test.old}/posts/2011-12-24-second-post.md +0 -0
- data/{test → test.old}/posts/static-page.md +0 -0
- data/{test → test.old}/test_helper.rb +0 -0
- metadata +158 -87
- data/example/Gemfile +0 -5
- data/example/config.ru +0 -8
- data/example/posts/2010-06-17-pythton-is-great.md +0 -9
- data/example/posts/2011-12-22-ruby-is-great.md +0 -16
- data/lib/schreihals/actions.rb +0 -45
- data/lib/schreihals/document.rb +0 -52
- data/lib/templates/first-post.md.tt +0 -1
- data/lib/templates/new-post.md.tt +0 -13
- data/lib/templates/new_blog/posts/.gitkeep +0 -0
- data/lib/templates/new_blog/public/media/.gitkeep +0 -0
- data/test/document_test.rb +0 -41
data/example/Gemfile
DELETED
data/example/config.ru
DELETED
@@ -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.
|
data/lib/schreihals/actions.rb
DELETED
@@ -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
|
data/lib/schreihals/document.rb
DELETED
@@ -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
|
File without changes
|
File without changes
|
data/test/document_test.rb
DELETED
@@ -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
|