dynamicmatic 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /pkg
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009 Nathan Weizenbaum
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # DynamicMatic
2
+
3
+ DynamicMatic is a tiny [Sinatra](http://sinatrarb.com) extension
4
+ that integrates Sinatra with [StaticMatic](http://staticmatic.rubyforge.org).
5
+ It allows most of your site to be static
6
+ while having a few dynamic pages that can use the StaticMatic layouts and partials.
7
+
8
+ ## Setup
9
+
10
+ Your Sinatra and StaticMatic apps live side-by-side.
11
+ The StaticMatic `site` directory is used as the directory for Sinatra's public files,
12
+ and the `src` directory contains the source for the static pages
13
+ and the layouts that are shared between StaticMatic and Sinatra.
14
+ Otherwise the standard Sinatra directories are used.
15
+
16
+ If the Sinatra `:root` option is changed,
17
+ DynamicMatic will respect that and set the StaticMatic paths appropriately.
18
+
19
+ ## Usage
20
+
21
+ If you're using a classic-style Sinatra application,
22
+ all you have to do is `require 'sinatra/dynamicmatic'`.
23
+ If you're using a modular application,
24
+ you'll also have to `include Sinatra::DynamicMatic`
25
+ in your `Sinatra::Base` subclass.
26
+
27
+ ## How it Works
28
+
29
+ The static pages and stylesheets in the StaticMatic `src` directory
30
+ are served statically - they should be compiled before the server is started.
31
+ This can be done using `staticmatic.run("build")` in your Sinatra app.
32
+
33
+ Any dynamic Sinatra pages can make use of the StaticMatic layouts and helpers,
34
+ but are rendered dynamically on each request.
35
+
36
+ ## Layouts
37
+
38
+ StaticMatic layouts are made available as normal Sinatra templates.
39
+ For example, if you have `src/layouts/application.haml` and `src/layouts/help.haml`,
40
+ `application.haml` will be used as the `:application` template,
41
+ and `help.haml` will be used as the `:help` template.
42
+ `application.haml` will *also* be used for the default layout for Sinatra pages.
43
+
44
+ ## Helpers
45
+
46
+ All the StaticMatic helpers, including those for partial-rendering,
47
+ are available in Sinatra views.
48
+ The reverse is not true;
49
+ Sinatra helpers are generally not available for StaticMatic pages,
50
+ since they are rendered statically.
51
+
52
+ Sinatra helpers are, however, available for StaticMatic layouts
53
+ **but only when they're being used for dynamic views**.
54
+ It's not safe to rely on them being there,
55
+ although you can check for their existence with `defined?`
56
+ and call them if they're there.
57
+
58
+ ## Configuration
59
+
60
+ StaticMatic is configured using `src/configuration.rb`.
61
+ Sinatra is configured using the `set` method.
62
+ In other words, configuration happens as usual.
63
+
64
+ DynamicMatic itself is configured in the Sinatra manner, with `set`.
65
+ Currently it only has one option:
66
+
67
+ * `compile_on_start`: Whether to compile the StaticMatic site
68
+ when the Sinatra app is started.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "dynamicmatic"
5
+ gemspec.summary = "Dynamic StaticMatic pages with Sinatra."
6
+ gemspec.description = <<DESCRIPTION
7
+ DynamicMatic is a tiny Sinatra extension that integrates Sinatra with StaticMatic.
8
+ It allows most of your site to be static
9
+ while having a few dynamic pages that can use the StaticMatic layouts and partials.
10
+ DESCRIPTION
11
+ gemspec.email = "nex342@gmail.com"
12
+ gemspec.homepage = "http://github.com/nex3/dynamicmatic"
13
+ gemspec.authors = ["Nathan Weizenbaum"]
14
+ #gemspec.add_dependency 'sinatra', '>= 0.10.1'
15
+ #gemspec.add_dependency 'staticmatic', '>= 0.10.1'
16
+ gemspec.has_rdoc = false
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 3
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dynamicmatic}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nathan Weizenbaum"]
12
+ s.date = %q{2009-11-11}
13
+ s.description = %q{DynamicMatic is a tiny Sinatra extension that integrates Sinatra with StaticMatic.
14
+ It allows most of your site to be static
15
+ while having a few dynamic pages that can use the StaticMatic layouts and partials.
16
+ }
17
+ s.email = %q{nex342@gmail.com}
18
+ s.extra_rdoc_files = [
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ "MIT-LICENSE",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION.yml",
27
+ "dynamicmatic.gemspec",
28
+ "lib/sinatra/dynamicmatic.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/nex3/dynamicmatic}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{Dynamic StaticMatic pages with Sinatra.}
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
@@ -0,0 +1,41 @@
1
+ require 'sinatra/base'
2
+ require 'staticmatic'
3
+
4
+ module Sinatra
5
+ module DynamicMatic
6
+ def self.registered(app)
7
+ app.set :lock, true
8
+ app.set :public, Proc.new {app.root && File.join(app.root, 'site')}
9
+
10
+ configuration = StaticMatic::Configuration.new
11
+
12
+ config_file = "#{app.root}/src/configuration.rb"
13
+
14
+ if File.exists?(config_file)
15
+ config = File.read(config_file)
16
+ eval(config)
17
+ end
18
+
19
+ staticmatic = StaticMatic::Base.new(app.root, configuration)
20
+ app.set :_staticmatic, staticmatic
21
+
22
+ Dir[File.join(app._staticmatic.src_dir, "layouts", "*.haml")].each do |layout|
23
+ name = layout[/([^\/]*)\.haml$/, 1].to_sym
24
+ haml = File.read(layout)
25
+ app.template(name) {haml}
26
+ app.layout {haml} if name == :application
27
+ end
28
+
29
+ before do
30
+ @staticmatic = staticmatic
31
+ staticmatic.instance_variable_set('@current_page', request.path_info)
32
+ end
33
+ end
34
+
35
+ def staticmatic
36
+ _staticmatic
37
+ end
38
+ end
39
+
40
+ register DynamicMatic
41
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynamicmatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Weizenbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-11 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: |
17
+ DynamicMatic is a tiny Sinatra extension that integrates Sinatra with StaticMatic.
18
+ It allows most of your site to be static
19
+ while having a few dynamic pages that can use the StaticMatic layouts and partials.
20
+
21
+ email: nex342@gmail.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - README.md
28
+ files:
29
+ - .gitignore
30
+ - MIT-LICENSE
31
+ - README.md
32
+ - Rakefile
33
+ - VERSION.yml
34
+ - dynamicmatic.gemspec
35
+ - lib/sinatra/dynamicmatic.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/nex3/dynamicmatic
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Dynamic StaticMatic pages with Sinatra.
64
+ test_files: []
65
+