spinebox 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +14 -5
- data/lib/spinebox/base.rb +1 -0
- data/lib/spinebox/compiler.rb +24 -4
- data/lib/spinebox/erb_context.rb +17 -6
- data/lib/spinebox/templates/app/app/helpers/link_helper.rb +9 -0
- data/lib/spinebox/version.rb +1 -1
- metadata +19 -18
data/README.textile
CHANGED
@@ -7,6 +7,8 @@ A ready to use spine.js rack skeleton builder with development server, routes, c
|
|
7
7
|
* Develop in coffee-script and sass with fantastic sprockets asset serving
|
8
8
|
* Use generators and scaffolding just like with rails
|
9
9
|
* Compile assets and serve the whole app completely static
|
10
|
+
* Use partials and helpers in your view just like in rails
|
11
|
+
* Compilation only updates actually changed files. This is a premise for delta deployment.
|
10
12
|
|
11
13
|
h3. Installation
|
12
14
|
|
@@ -16,11 +18,7 @@ h3. Usage
|
|
16
18
|
|
17
19
|
Create your javascript app or HTML files just as you're used to it.
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
bc.. render :partial => "navigation.html"
|
22
|
-
|
23
|
-
h4. Create new project
|
21
|
+
h4. Create New Project
|
24
22
|
|
25
23
|
bc.. # Create new project an start developing
|
26
24
|
$ spinebox new blog
|
@@ -28,6 +26,17 @@ $ cd blog
|
|
28
26
|
$ spinebox server
|
29
27
|
$ open http://localhost:3000/index.html
|
30
28
|
|
29
|
+
h4. Use Partials and Helpers
|
30
|
+
|
31
|
+
Partials are prefixed with a @_@ to declare them a partial. So you can create a @_navigation.html.erb@ and use it, e.g.
|
32
|
+
in the @index.html.erb@ with:
|
33
|
+
|
34
|
+
bc.. <%= render :partial => "index.html" %>
|
35
|
+
|
36
|
+
p. Helpers are in the helper folder and included by default in any view. So if you want to create special links, etc. that
|
37
|
+
you reuse throughout your project simply create a method named @link_to@ in the helper, any any view and partial will have it
|
38
|
+
accessible.
|
39
|
+
|
31
40
|
h4. Generate models, views and controllers
|
32
41
|
|
33
42
|
bc.. # Generate a model view and a controller
|
data/lib/spinebox/base.rb
CHANGED
data/lib/spinebox/compiler.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Spinebox
|
2
2
|
module Compiler
|
3
3
|
|
4
|
+
require "digest"
|
5
|
+
|
4
6
|
# Compiles the assets and the views into the public folder
|
5
7
|
def self.compile
|
6
8
|
Spinebox.config.concatenate = true
|
@@ -19,24 +21,42 @@ module Spinebox
|
|
19
21
|
|
20
22
|
def self.compile_javascripts
|
21
23
|
asset = Spinebox.assets["application.js"]
|
22
|
-
|
24
|
+
path = File.join("public/assets", asset.logical_path)
|
25
|
+
|
26
|
+
write_asset!(asset, path) if asset_updated?(asset, path)
|
23
27
|
end
|
24
28
|
|
25
29
|
def self.compile_stylesheets
|
26
30
|
asset = Spinebox.assets["application.css"]
|
27
|
-
|
31
|
+
path = File.join("public/assets", asset.logical_path)
|
32
|
+
|
33
|
+
write_asset!(asset, path) if asset_updated?(asset, path)
|
28
34
|
end
|
29
35
|
|
30
36
|
def self.compile_views
|
31
37
|
Spinebox.views.each_logical_path do |logical_path|
|
32
38
|
next if logical_path.start_with?("_")
|
33
39
|
asset = Spinebox.views[logical_path]
|
34
|
-
|
40
|
+
path = File.join("public", asset.logical_path)
|
41
|
+
|
42
|
+
write_asset!(asset, path) if asset_updated?(asset, path)
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
38
46
|
def self.copy_images
|
39
|
-
FileUtils.cp_r "app/assets/images/.", "public/assets"
|
47
|
+
FileUtils.cp_r "app/assets/images/.", "public/assets", :preserve => true
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.asset_updated?(asset, path)
|
51
|
+
return true unless File.exists?(path)
|
52
|
+
Digest::SHA2.file(path).hexdigest != Digest::SHA2.hexdigest(asset.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.write_asset!(asset, path)
|
56
|
+
asset.write_to(path)
|
57
|
+
time = Time.now
|
58
|
+
File.utime(time, time, path)
|
59
|
+
puts path
|
40
60
|
end
|
41
61
|
|
42
62
|
end
|
data/lib/spinebox/erb_context.rb
CHANGED
@@ -29,6 +29,7 @@ module Spinebox
|
|
29
29
|
raise RenderError, "Partial needs a file extension" if params[:partial].split(".").size == 0
|
30
30
|
|
31
31
|
partial = Spinebox.views["_#{params[:partial]}"]
|
32
|
+
|
32
33
|
raise RenderError, "Partial not found" if partial.nil?
|
33
34
|
|
34
35
|
partial.to_s
|
@@ -43,21 +44,31 @@ module Spinebox
|
|
43
44
|
|
44
45
|
# Build a javascript tag with body options
|
45
46
|
def javascript_tag_for asset, options = {}
|
46
|
-
"<script src='assets/#{asset.logical_path}#{"?body=1" if options[:body]}' type='text/javascript'></script>"
|
47
|
+
"<script src='/assets/#{asset.logical_path}#{"?body=1" if options[:body]}' type='text/javascript'></script>"
|
47
48
|
end
|
48
49
|
|
49
50
|
# Build a stylesheet link with body options
|
50
51
|
def stylesheet_tag_for asset, new_options = {}
|
51
52
|
options = { :media => "all", :rel => "stylesheet" }.merge!(new_options)
|
52
|
-
"<link href='assets/#{asset.logical_path}#{"?body=1" if options[:body]}' media='#{options[:media]}' rel='#{options[:rel]}' type='text/css'>"
|
53
|
+
"<link href='/assets/#{asset.logical_path}#{"?body=1" if options[:body]}' media='#{options[:media]}' rel='#{options[:rel]}' type='text/css'>"
|
53
54
|
end
|
54
55
|
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
class << self
|
59
|
+
|
60
|
+
# Load helpers and include into sprockets context
|
61
|
+
def load_helpers!
|
62
|
+
Spinebox::ERBContext.class_eval do
|
63
|
+
Dir["app/helpers/*"].each do |helper|
|
64
|
+
require("./#{helper}")
|
65
|
+
include Spinebox.const_get(File.basename(helper, ".rb").classify)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
::Sprockets::Context.instance_eval do
|
70
|
+
include Spinebox::ERBContext
|
71
|
+
end
|
61
72
|
end
|
62
73
|
end
|
63
74
|
|
data/lib/spinebox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sprockets
|
17
|
-
requirement: &
|
17
|
+
requirement: &70299237085840 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.1.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70299237085840
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rack
|
28
|
-
requirement: &
|
28
|
+
requirement: &70299237085260 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.4.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70299237085260
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: coffee-script
|
39
|
-
requirement: &
|
39
|
+
requirement: &70299237084800 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.2.0
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70299237084800
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: eco
|
50
|
-
requirement: &
|
50
|
+
requirement: &70299237084320 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 1.0.0
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70299237084320
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sass
|
61
|
-
requirement: &
|
61
|
+
requirement: &70299237106620 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 3.1.15
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70299237106620
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: colorize
|
72
|
-
requirement: &
|
72
|
+
requirement: &70299237106160 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.5.8
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70299237106160
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: activesupport
|
83
|
-
requirement: &
|
83
|
+
requirement: &70299237105700 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 3.2.2
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70299237105700
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: thin
|
94
|
-
requirement: &
|
94
|
+
requirement: &70299237105240 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: 1.3.1
|
100
100
|
type: :runtime
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70299237105240
|
103
103
|
description: A ready to use spine.js rack skeleton builder with development server,
|
104
104
|
routes, config and precompile support
|
105
105
|
email:
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/spinebox/templates/app/app/assets/javascripts/lib/spine/route.coffee
|
150
150
|
- lib/spinebox/templates/app/app/assets/javascripts/lib/spine/spine.coffee
|
151
151
|
- lib/spinebox/templates/app/app/assets/stylesheets/application.css.scss
|
152
|
+
- lib/spinebox/templates/app/app/helpers/link_helper.rb
|
152
153
|
- lib/spinebox/templates/app/app/views/_partial.html.erb
|
153
154
|
- lib/spinebox/templates/app/app/views/index.html.erb
|
154
155
|
- lib/spinebox/templates/app/config.ru
|