jrhicks-static-generators 0.4.7 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -17
- data/Rakefile +1 -1
- data/rails_generators/static_app/templates/faceted_search/lib/date_range_facet.rb +44 -42
- data/rails_generators/static_app/templates/faceted_search/lib/facet.rb +26 -5
- data/rails_generators/static_scaffold/templates/layout.html.erb +5 -5
- data/static-generators.gemspec +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -1,44 +1,45 @@
|
|
1
1
|
## Static Scaffolds
|
2
2
|
|
3
|
-
|
3
|
+
Scaffold usable rails apps that are easy to edit.
|
4
4
|
|
5
5
|
## Install Gem
|
6
6
|
|
7
7
|
gem sources -a http://gems.github.com
|
8
|
-
|
8
|
+
sudogem install jrhicks-static-generators
|
9
9
|
|
10
|
-
##
|
10
|
+
## Create Base Rails App
|
11
11
|
|
12
12
|
rails project_name -m http://github.com/jrhicks/static-scaffolds/raw/master/rails_templates/static_base.rb
|
13
13
|
|
14
|
-
## Usage
|
14
|
+
## Basic Usage
|
15
15
|
|
16
16
|
ruby script/generate static_app
|
17
17
|
ruby script/generate static_gen_specs MyModel
|
18
18
|
ruby script/generate static_scaffold MyModel
|
19
19
|
|
20
|
-
## Demo
|
20
|
+
## Demo App Walkthrough
|
21
21
|
|
22
|
+
gem sources -a http://gems.github.com
|
23
|
+
sudo gem install jrhicks-static-generators
|
22
24
|
rails address_book -m http://github.com/jrhicks/static-scaffolds/raw/master/rails_templates/static_base.rb
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
http://localhost:3000/contacts
|
25
|
+
ruby script/generate model contact full_name:string birth_date:datetime email:string phone:string city:string state:string
|
26
|
+
rake db:migrate
|
27
|
+
ruby script/generate static_gen_specs contact -f
|
28
|
+
ruby script/generate static_scaffold contact -f
|
29
|
+
rake db:populate_fake_contacts
|
30
|
+
ruby script/server
|
31
|
+
http://localhost:3000/contacts
|
31
32
|
|
32
33
|
## Development
|
33
34
|
|
34
|
-
|
35
|
+
git clone git://github.com/jrhicks/static-scaffolds.git
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
gem install echoe
|
38
|
+
rake manifest
|
38
39
|
rake build
|
39
40
|
rake install
|
40
41
|
|
41
42
|
## Author
|
42
43
|
|
43
|
-
|
44
|
+
Jeffrey Hicks
|
44
45
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('static-generators', '0.
|
5
|
+
Echoe.new('static-generators', '0.5.0') do |p|
|
6
6
|
p.project = "staticgenerators"
|
7
7
|
p.description = "Generate attractive interfaces that are easy to edit."
|
8
8
|
p.url = "http://github.com/jrhicks/static-scaffolds"
|
@@ -1,57 +1,59 @@
|
|
1
|
-
class FacetedSearch::Facet
|
1
|
+
class FacetedSearch::DateRangeFacet < FacetedSearch::Facet
|
2
2
|
|
3
|
-
#
|
3
|
+
# Set upper and lower limit values for an attribute
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def initialize(attribute, title, table_name, session)
|
6
|
+
@title = title
|
7
|
+
@attribute = attribute
|
8
|
+
@table_name = table_name
|
9
|
+
@session = session
|
10
|
+
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
12
|
+
def refined(scope)
|
13
|
+
scope = scope.scoped :conditions => ["#{@table_name}.#{@attribute} <= ?", upper_limit_date] unless upper_limit.blank?
|
14
|
+
scope = scope.scoped :conditions => ["#{@table_name}.#{@attribute} >= ?", lower_limit_date] unless lower_limit.blank?
|
15
|
+
return scope
|
13
16
|
end
|
14
17
|
|
18
|
+
def upper_limit_param_name()
|
19
|
+
"#{@table_name}_date_ul_#{@attribute}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def lower_limit_param_name()
|
23
|
+
"#{@table_name}_date_ll_#{@attribute}"
|
24
|
+
end
|
25
|
+
|
15
26
|
def is_active?
|
16
|
-
|
27
|
+
(not lower_limit.blank?) or (not upper_limit.blank?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def turn_off_param
|
31
|
+
"#{@table_name}_turn_off_#{@attribute}"
|
17
32
|
end
|
18
33
|
|
19
34
|
def turn_off
|
20
|
-
|
35
|
+
@session[lower_limit_param_name]=nil
|
36
|
+
@session[upper_limit_param_name]=nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def upper_limit_date
|
40
|
+
Date.parse(upper_limit)
|
21
41
|
end
|
22
|
-
|
23
|
-
def
|
24
|
-
|
42
|
+
|
43
|
+
def lower_limit_date
|
44
|
+
Date.parse(lower_limit)
|
25
45
|
end
|
26
|
-
|
27
|
-
def
|
28
|
-
|
46
|
+
|
47
|
+
def upper_limit
|
48
|
+
@session[upper_limit_param_name]
|
29
49
|
end
|
30
|
-
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def turn_off_if_needed(params)
|
38
|
-
if params.keys.include?(turn_off_param) and is_active?
|
39
|
-
turn_off
|
40
|
-
return true
|
41
|
-
else
|
42
|
-
return false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def update_with(params)
|
47
|
-
value_changed = turn_off_if_needed(params)
|
48
|
-
for p in parameter_names
|
49
|
-
if params[p]!=nil and @session[p]!=params[p]
|
50
|
-
value_changed=true
|
51
|
-
@session[p] = params[p]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
return value_changed
|
50
|
+
|
51
|
+
def lower_limit
|
52
|
+
@session[lower_limit_param_name]
|
53
|
+
end
|
54
|
+
|
55
|
+
def parameter_names
|
56
|
+
[upper_limit_param_name, lower_limit_param_name]
|
55
57
|
end
|
56
58
|
|
57
59
|
end
|
@@ -2,12 +2,24 @@ class FacetedSearch::Facet
|
|
2
2
|
|
3
3
|
# facilitate complex queries by managing session data from request paramaters
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
attr_reader :title
|
6
|
+
|
7
|
+
def initialize()
|
8
8
|
raise Exception.new("initialize is a subclase responsibility")
|
9
9
|
end
|
10
10
|
|
11
|
+
def turn_off_param
|
12
|
+
raise Exception.new("turn_off_param is a subclass responsibility")
|
13
|
+
end
|
14
|
+
|
15
|
+
def is_active?
|
16
|
+
raise Exception.new("is_on? is a subclass responsibility")
|
17
|
+
end
|
18
|
+
|
19
|
+
def turn_off
|
20
|
+
raise Exception.new("turn_off is a subclass responsibility")
|
21
|
+
end
|
22
|
+
|
11
23
|
def refined
|
12
24
|
raise Exception.new("refine is a subclass responsibility")
|
13
25
|
end
|
@@ -22,10 +34,19 @@ class FacetedSearch::Facet
|
|
22
34
|
return params
|
23
35
|
end
|
24
36
|
|
37
|
+
def turn_off_if_needed(params)
|
38
|
+
if params.keys.include?(turn_off_param) and is_active?
|
39
|
+
turn_off
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
25
46
|
def update_with(params)
|
26
|
-
value_changed=
|
47
|
+
value_changed = turn_off_if_needed(params)
|
27
48
|
for p in parameter_names
|
28
|
-
if params[p]!=nil
|
49
|
+
if params[p]!=nil and @session[p]!=params[p]
|
29
50
|
value_changed=true
|
30
51
|
@session[p] = params[p]
|
31
52
|
end
|
@@ -19,10 +19,10 @@
|
|
19
19
|
<div class="span-5">
|
20
20
|
<div class="model">
|
21
21
|
<div class="model_header ui-corner-tl">
|
22
|
-
<%=
|
22
|
+
<%=gen_spec.plural_title%>
|
23
23
|
</div>
|
24
24
|
<div class="model_facets">
|
25
|
-
<%%=render :partial=>"<%=
|
25
|
+
<%%=render :partial=>"<%=gen_spec.plural_name%>/facet_form"%>
|
26
26
|
</div>
|
27
27
|
</div> <!-- end model selector -->
|
28
28
|
</div> <!-- end left_column -->
|
@@ -49,12 +49,12 @@
|
|
49
49
|
</div> <!-- end presentation selector -->
|
50
50
|
|
51
51
|
<!-- facet remove bar -->
|
52
|
-
|
52
|
+
<%%if <%=gen_spec.singular_name%>_search.active_facets.length != 0%>
|
53
53
|
<div class="remove_facets_panel">
|
54
|
-
|
54
|
+
<%%@search=<%=gen_spec.singular_name%>_search%>
|
55
55
|
<%%=render :partial=>"faceted_search/active_facets"%>
|
56
56
|
</div>
|
57
|
-
|
57
|
+
<%%end%>
|
58
58
|
<!-- end facet remove bar -->
|
59
59
|
|
60
60
|
<div class="presentation_window">
|
data/static-generators.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{static-generators}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jeffrey Hicks"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-20}
|
10
10
|
s.description = %q{Generate attractive interfaces that are easy to edit.}
|
11
11
|
s.email = %q{jrhicks (at) gmail (dot) com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "README.md", "tasks/deployment.rake", "TODO"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jrhicks-static-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Hicks
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|