Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename to statics

  • Loading branch information...
commit 6b85265e7edbd7873cbba8d18b61bebcca0bc499 1 parent 53cd742
@svenfuchs authored
Showing with 94 additions and 75 deletions.
  1. +0 −8 lib/slick.rb
  2. +0 −13 lib/slick/builder.rb
  3. +0 −10 lib/slick/model.rb
  4. +0 −3  lib/slick/views/page/error.html.erb
  5. +8 −0 lib/statics.rb
  6. +13 −0 lib/statics/builder.rb
  7. +8 −2 lib/{slick → statics}/builder/base.rb
  8. +1 −1  lib/{slick → statics}/builder/blog.rb
  9. +1 −1  lib/{slick → statics}/builder/content.rb
  10. +1 −1  lib/{slick → statics}/builder/page.rb
  11. +2 −2 lib/{slick → statics}/builder/section.rb
  12. +10 −0 lib/statics/model.rb
  13. +1 −1  lib/{slick → statics}/model/base.rb
  14. +1 −1  lib/{slick → statics}/model/content.rb
  15. +1 −1  lib/{slick → statics}/model/section.rb
  16. +3 −0  lib/{slick → statics}/views/blog/archive.html.erb
  17. 0  lib/{slick → statics}/views/blog/feed.atom.builder
  18. 0  lib/{slick → statics}/views/blog/index.html.erb
  19. +2 −0  lib/{slick → statics}/views/blog/show.html.erb
  20. 0  lib/{slick → statics}/views/layouts/application.html.erb
  21. +5 −0 lib/statics/views/page/error.html.erb
  22. +2 −0  lib/{slick → statics}/views/page/index.html.erb
  23. 0  test/_root/data/projects/{i18.html → i18n.html}
  24. +24 −20 test/builder_test.rb
  25. +1 −1  test/model/base_test.rb
  26. +1 −1  test/model/content_test.rb
  27. +1 −1  test/model/section_test.rb
  28. +7 −7 test/test_helper.rb
  29. +1 −1  test/view_test.rb
View
8 lib/slick.rb
@@ -1,8 +0,0 @@
-require 'active_support/core_ext/object/singleton_class'
-require 'action_view'
-
-module Slick
- autoload :Builder, 'slick/builder'
- autoload :Data, 'slick/data'
- autoload :Model, 'slick/model'
-end
View
13 lib/slick/builder.rb
@@ -1,13 +0,0 @@
-module Slick::Builder
- autoload :Base, 'slick/builder/base'
- autoload :Blog, 'slick/builder/blog'
- autoload :Content, 'slick/builder/content'
- autoload :Page, 'slick/builder/page'
- autoload :Section, 'slick/builder/section'
-
- class << self
- def create(parent, object, data)
- const_get(object.type.camelize).new(data, parent)
- end
- end
-end
View
10 lib/slick/model.rb
@@ -1,10 +0,0 @@
-require 'core_ext/string/camelize'
-
-module Slick::Model
- autoload :Base, 'slick/model/base'
- autoload :Blog, 'slick/model/blog'
- autoload :Content, 'slick/model/content'
- autoload :Page, 'slick/model/page'
- autoload :Section, 'slick/model/section'
- autoload :Site, 'slick/model/site'
-end
View
3  lib/slick/views/page/error.html.erb
@@ -1,3 +0,0 @@
-<div id="error">
- <%= section.body.html_safe %>
-</div>
View
8 lib/statics.rb
@@ -0,0 +1,8 @@
+require 'active_support/core_ext/object/singleton_class'
+require 'action_view'
+
+module Statics
+ autoload :Builder, 'Statics/builder'
+ autoload :Data, 'Statics/data'
+ autoload :Model, 'Statics/model'
+end
View
13 lib/statics/builder.rb
@@ -0,0 +1,13 @@
+module Statics::Builder
+ autoload :Base, 'Statics/builder/base'
+ autoload :Blog, 'Statics/builder/blog'
+ autoload :Content, 'Statics/builder/content'
+ autoload :Page, 'Statics/builder/page'
+ autoload :Section, 'Statics/builder/section'
+
+ class << self
+ def create(parent, object, data)
+ const_get(object.type.camelize).new(data, parent)
+ end
+ end
+end
View
10 lib/slick/builder/base.rb → lib/statics/builder/base.rb
@@ -2,7 +2,7 @@
require 'logger'
require 'abstract_controller'
-module Slick::Builder
+module Statics::Builder
class Base
class << self
def controller_path
@@ -24,6 +24,7 @@ def initialize(data, parent = nil)
@data = data
@config = ActiveSupport::InheritableOptions.new(data[:config] || {})
@request = ActionDispatch::Request.new({ 'HTTP_HOST' => 'svenfuchs.com' })
+ super()
end
def url(content)
@@ -40,11 +41,16 @@ def page_title
end
protected
+
+ def layout
+ layout = content.layout rescue section.layout
+ layout || :default
+ end
def render(template, target, options = {})
# TODO lookup_context, at least formats, seem messed up after we've rendered once
@lookup_context = ActionView::LookupContext.new(self.class._view_paths, details_for_lookup)
- html = super(options.merge(:template => template, :layout => layout, :locals => data))
+ html = super(options.reverse_merge(:template => template, :layout => layout, :locals => data))
write(target, html) && html
end
View
2  lib/slick/builder/blog.rb → lib/statics/builder/blog.rb
@@ -1,4 +1,4 @@
-module Slick::Builder
+module Statics::Builder
class Blog < Section
def build
super
View
2  lib/slick/builder/content.rb → lib/statics/builder/content.rb
@@ -1,6 +1,6 @@
require 'fileutils'
-module Slick::Builder
+module Statics::Builder
class Content < Base
end
end
View
2  lib/slick/builder/page.rb → lib/statics/builder/page.rb
@@ -1,4 +1,4 @@
-module Slick::Builder
+module Statics::Builder
class Page < Section
end
end
View
4 lib/slick/builder/section.rb → lib/statics/builder/section.rb
@@ -1,4 +1,4 @@
-module Slick::Builder
+module Statics::Builder
class Section < Base
attr_reader :data, :site, :section, :parent
@@ -19,7 +19,7 @@ def build_index
end
def build_children
- section.children.each { |child| Slick::Builder.create(self, child, data.merge(:section => child)).build }
+ section.children.each { |child| Statics::Builder.create(self, child, data.merge(:section => child)).build }
end
def root?
View
10 lib/statics/model.rb
@@ -0,0 +1,10 @@
+require 'core_ext/string/camelize'
+
+module Statics::Model
+ autoload :Base, 'Statics/model/base'
+ autoload :Blog, 'Statics/model/blog'
+ autoload :Content, 'Statics/model/content'
+ autoload :Page, 'Statics/model/page'
+ autoload :Section, 'Statics/model/section'
+ autoload :Site, 'Statics/model/site'
+end
View
2  lib/slick/model/base.rb → lib/statics/model/base.rb
@@ -1,7 +1,7 @@
require 'pathname'
require 'active_support/core_ext/module/delegation'
-module Slick::Model
+module Statics::Model
class Base
YAML_PREAMBLE = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
View
2  lib/slick/model/content.rb → lib/statics/model/content.rb
@@ -2,7 +2,7 @@
require 'core_ext/hash/symbolize_keys'
require 'core_ext/string/titleize'
-module Slick::Model
+module Statics::Model
class Content < Base
PUBLISHED_AT_PATTERN = %r((?:^|\/)([\d]{4}[-_][\d]{1,2}[-_][\d]{1,2})[-_])
View
2  lib/slick/model/section.rb → lib/statics/model/section.rb
@@ -1,4 +1,4 @@
-module Slick::Model
+module Statics::Model
class Section < Base
def initialize(path)
super
View
3  lib/slick/views/blog/archive.html.erb → lib/statics/views/blog/archive.html.erb
@@ -1,4 +1,7 @@
+<p><%= link_to "&larr; Home".html_safe, '/' %></p>
+
<h1>Archive</h1>
+
<ul id="archive">
<% section.archive.each do |year, posts| %>
<li>
View
0  lib/slick/views/blog/feed.atom.builder → lib/statics/views/blog/feed.atom.builder
File renamed without changes
View
0  lib/slick/views/blog/index.html.erb → lib/statics/views/blog/index.html.erb
File renamed without changes
View
2  lib/slick/views/blog/show.html.erb → lib/statics/views/blog/show.html.erb
@@ -1,3 +1,5 @@
+<p><%= link_to "&larr; Home".html_safe, '/' %></p>
+
<div id="post">
<%= content_tag :h1, content.title %>
<%= content.body.html_safe %>
View
0  lib/slick/views/layouts/application.html.erb → ...tatics/views/layouts/application.html.erb
File renamed without changes
View
5 lib/statics/views/page/error.html.erb
@@ -0,0 +1,5 @@
+<p><%= link_to "&larr; Home".html_safe, '/' %></p>
+
+<div id="error">
+ <%= section.body.html_safe %>
+</div>
View
2  lib/slick/views/page/index.html.erb → lib/statics/views/page/index.html.erb
@@ -1,3 +1,5 @@
+<p><%= link_to "&larr; Home".html_safe, '/' %></p>
+
<div id="page">
<%= content_tag :h1, section.title %>
<%= section.body.html_safe %>
View
0  test/_root/data/projects/i18.html → test/_root/data/projects/i18n.html
File renamed without changes
View
44 test/builder_test.rb
@@ -5,46 +5,50 @@ class BuilderTest < Test::Unit::TestCase
def setup
@config = {
:title => "Sven Fuchs",
- :root_dir => TEST_ROOT,
- :assets_dir => ASSETS_DIR,
- :stylesheets_dir => ASSETS_DIR + '/stylesheets'
+ :url => "http://svenfuchs.com",
+ :author => "Sven Fuchs",
+ :root_dir => ROOT_DIR,
+ :assets_dir => PUBLIC_DIR,
+ :stylesheets_dir => PUBLIC_DIR + '/stylesheets',
+ :javascripts_dir => PUBLIC_DIR + '/javascripts'
+
}
- @section = Slick::Model::Section.new(DATA_DIR)
+ @section = Statics::Model::Section.new(DATA_DIR)
FileUtils.rm_r(PUBLIC_DIR) rescue Errno::ENOENT
FileUtils.mkdir_p(PUBLIC_DIR)
end
test 'path for a root section is index' do
- root = Slick::Builder::Blog.new(:section => @section)
+ root = Statics::Builder::Blog.new(:section => @section)
assert_equal 'index', root.send(:path)
end
test 'path for a nested section is its section slug' do
- root = Slick::Builder::Blog.new(:section => @section)
- nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
+ root = Statics::Builder::Blog.new(:section => @section)
+ nested = Statics::Builder::Blog.new({ :section => @section.children.last }, root)
assert_equal 'projects', nested.send(:path)
end
test "path for a nested nested section is its parent's section slug and sectin slug" do
- root = Slick::Builder::Blog.new(:section => @section)
- nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
- nested_nested = Slick::Builder::Blog.new({ :section => @section.children.last }, nested)
+ root = Statics::Builder::Blog.new(:section => @section)
+ nested = Statics::Builder::Blog.new({ :section => @section.children.last }, root)
+ nested_nested = Statics::Builder::Blog.new({ :section => @section.children.last }, nested)
assert_equal 'projects/projects', nested_nested.send(:path)
end
test 'path for a root section article is its article slug' do
- root = Slick::Builder::Blog.new(:section => @section.children.last)
- nested = Slick::Builder::Blog.new({ :section => @section.children.last }, root)
+ root = Statics::Builder::Blog.new(:section => @section.children.last)
+ nested = Statics::Builder::Blog.new({ :section => @section.children.last }, root)
assert_equal 'projects', nested.send(:path)
end
test 'build' do
- Slick::Builder::Blog.new(:config => @config, :section => @section).build
+ Statics::Builder::Blog.new(:config => @config, :section => @section).build
assert File.exists?(PUBLIC_DIR + '/index.html')
- assert File.exists?(PUBLIC_DIR + '/2009/07/06/using_ruby_1_9_ripper.html')
+ assert File.exists?(PUBLIC_DIR + '/2009/07/06/using-ruby-1-9-ripper.html')
assert File.exists?(PUBLIC_DIR + '/articles.html')
- assert File.exists?(PUBLIC_DIR + '/articles/articles_child.html')
+ assert File.exists?(PUBLIC_DIR + '/articles/child.html')
assert File.exists?(PUBLIC_DIR + '/projects.html')
assert File.exists?(PUBLIC_DIR + '/projects/i18n.html')
assert File.exists?(PUBLIC_DIR + '/contact.html')
@@ -52,26 +56,26 @@ def setup
test 'build w/ the application (default) layout' do
@section.attributes['layout'] = 'does_not_exist'
- assert_match /DOCTYPE html/, Slick::Builder.create(nil, @section, :config => @config, :section => @section).send(:build_index)
+ assert_match /DOCTYPE html/, Statics::Builder.create(nil, @section, :config => @config, :section => @section).send(:build_index)
end
test 'build w/ a builder specific layout' do
section = @section.children.detect { |child| child.layout == nil }
- assert_match /page layout/, Slick::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
+ assert_match /page layout/, Statics::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
end
test 'build w/ a custom layout' do
section = @section.children.detect { |child| child.layout == 'custom' }
- assert_match /custom layout/, Slick::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
+ assert_match /custom layout/, Statics::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
end
test 'build w/ a custom template' do
section = @section.children.detect { |child| child.template == 'custom' }
- assert_match /custom template/, Slick::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
+ assert_match /custom template/, Statics::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
end
test 'build w/ an overwritten page template' do
section = @section.children.detect { |child| child.title == 'Contact' }
- assert_match /Custom Page/, Slick::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
+ assert_match /Custom Page/, Statics::Builder.create(nil, section, :config => @config, :section => section).send(:build_index)
end
end
View
2  test/model/base_test.rb
@@ -2,7 +2,7 @@
class ModelBaseTest < Test::Unit::TestCase
def model(path)
- Slick::Model::Base.new(path)
+ Statics::Model::Base.new(path)
end
test "slug is the underscored title (so it can be used in urls)" do
View
2  test/model/content_test.rb
@@ -2,7 +2,7 @@
class ModelContentTest < Test::Unit::TestCase
test "published_at_from_file_name parses a date from the file's basename" do
- content = Slick::Model::Content.new(DATA_DIR + '/_posts/2009-07-05-foo.html')
+ content = Statics::Model::Content.new(DATA_DIR + '/_posts/2009-07-05-foo.html')
date = content.send(:published_at_from_filename)
assert_equal '2009-07-05', date.to_s
end
View
2  test/model/section_test.rb
@@ -1,7 +1,7 @@
require File.expand_path('../../test_helper', __FILE__)
class ModelSectionTest < Test::Unit::TestCase
- include Slick::Model
+ include Statics::Model
test 'determine_type returns Page for a page file' do
assert_equal 'page', Section.new(DATA_DIR + '/contact.html').send(:determine_type)
View
14 test/test_helper.rb
@@ -9,13 +9,13 @@
require 'test/unit'
require 'pp'
-require 'slick'
+require 'Statics'
require File.expand_path('../test_declarative.rb', __FILE__)
-TEST_ROOT = File.expand_path('../_root', __FILE__)
-DATA_DIR = TEST_ROOT + '/data'
-ASSETS_DIR = TEST_ROOT + '/assets'
-PUBLIC_DIR = TEST_ROOT + '/public'
-VIEWS_DIR = TEST_ROOT + '/views'
+ROOT_DIR = File.expand_path('../_root', __FILE__)
+DATA_DIR = ROOT_DIR + '/data'
+ASSETS_DIR = ROOT_DIR + '/assets'
+PUBLIC_DIR = ROOT_DIR + '/public'
+VIEWS_DIR = ROOT_DIR + '/views'
-Slick::Builder::Base.prepend_view_path(VIEWS_DIR)
+Statics::Builder::Base.prepend_view_path(VIEWS_DIR)
View
2  test/view_test.rb
@@ -2,7 +2,7 @@
#
# class ViewTest < Test::Unit::TestCase
# test 'simple render' do
-# section = Slick::Model::Section.new('path/to/foo')
+# section = Statics::Model::Section.new('path/to/foo')
# section.attributes = { :title => 'da blog' }
# html = ActionView::Base.new([VIEWS_DIR]).render(:file => 'blog/index', :locals => { :section => section })
# assert_match /#{section.title}/, html
Please sign in to comment.
Something went wrong with that request. Please try again.