guidelines 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rvmrc +12 -0
- data/.wiprc +13 -0
- data/.wiprc_fn +6 -0
- data/Gemfile +4 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/app/controllers/guidelines_controller.rb +25 -0
- data/app/helpers/guidelines_helper.rb +8 -0
- data/app/helpers/guidelines_helper/builder.rb +39 -0
- data/app/helpers/guidelines_helper/example.rb +13 -0
- data/app/views/guidelines/index.html.erb +7 -0
- data/config/locales/en.yml +4 -0
- data/config/routes.rb +5 -0
- data/guidelines.gems +2 -0
- data/guidelines.gemspec +21 -0
- data/lib/guidelines.rb +7 -0
- data/lib/guidelines/rails.rb +7 -0
- data/lib/guidelines/rails/engine.rb +7 -0
- data/lib/guidelines/version.rb +3 -0
- metadata +87 -0
data/.rvmrc
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
rvm use --create --install ruby-1.8.7@styleguides
|
2
|
+
|
3
|
+
if [[ -s "./styleguides.gems" ]]; then
|
4
|
+
if ! rvm gemset import styleguides.gems ; then
|
5
|
+
echo "ERROR: Unable to bootstrap the gems" >&2
|
6
|
+
fi
|
7
|
+
fi
|
8
|
+
|
9
|
+
# Bundle is available, non-custom config.
|
10
|
+
if command -v bundle >/dev/null && ! grep -q BUNDLE_FROZEN .bundle/config 2>/dev/null ; then
|
11
|
+
bundle install
|
12
|
+
fi
|
data/.wiprc
ADDED
data/.wiprc_fn
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
guidelines
|
2
|
+
==============================================================================
|
3
|
+
|
4
|
+
more to come, but it's basically (for now) a Rails engine for providing your
|
5
|
+
application with style guide(line)s against which to build your views.
|
6
|
+
|
7
|
+
...in which "view" is defined as:
|
8
|
+
|
9
|
+
* Rails templates
|
10
|
+
* Rails view-related controller logic (e.g., rendering html or json)
|
11
|
+
* DOM produced
|
12
|
+
* CSS presentation
|
13
|
+
* JS behavior
|
14
|
+
* Images/fonts/etc.
|
15
|
+
|
16
|
+
|
17
|
+
Requirements
|
18
|
+
------------------------------------------------------------------------------
|
19
|
+
|
20
|
+
* Rails
|
21
|
+
* nokogiri
|
22
|
+
* The ability to consider a "view" as incorporating all of the components
|
23
|
+
in the definition above and a desire to apply the same degree of
|
24
|
+
convention and attention-to-detail to views as to models/controllers/etc.
|
25
|
+
|
26
|
+
|
27
|
+
Installation
|
28
|
+
------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
gem install guidelines
|
31
|
+
|
32
|
+
|
33
|
+
Usage
|
34
|
+
------------------------------------------------------------------------------
|
35
|
+
|
36
|
+
Add examples to `app/views/guidelines`, in which nested folders are fine.
|
37
|
+
|
38
|
+
e.g.,
|
39
|
+
|
40
|
+
# app/views/guidelines/users/show.html.erb
|
41
|
+
<%= guideline_for('users#show') do |guideline| %>
|
42
|
+
<%= guideline.example do |example| -%>
|
43
|
+
<style type="text/css" media="screen">
|
44
|
+
/*
|
45
|
+
apply page-/example-specific styles here. should be few, as we're
|
46
|
+
really testing that things look good based on our app-wide styles.
|
47
|
+
*/
|
48
|
+
|
49
|
+
<%= example.selector %> > h1 {
|
50
|
+
font-weight : bold;
|
51
|
+
}
|
52
|
+
</style>
|
53
|
+
|
54
|
+
<article class="user" id="user_1">
|
55
|
+
<h1>user one</h1>
|
56
|
+
</article>
|
57
|
+
<%- end -%>
|
58
|
+
<%- end -%>
|
59
|
+
|
60
|
+
|
61
|
+
TODO
|
62
|
+
------------------------------------------------------------------------------
|
63
|
+
|
64
|
+
plenty
|
65
|
+
|
66
|
+
|
67
|
+
Contributors
|
68
|
+
------------------------------------------------------------------------------
|
69
|
+
|
70
|
+
* Corey Innis <http://github.com/coreyti>
|
71
|
+
Author
|
72
|
+
|
73
|
+
Acknowledgments
|
74
|
+
------------------------------------------------------------------------------
|
75
|
+
|
76
|
+
* The IfWeRanTheWorld team <http://ifwerantheworld.com/>
|
77
|
+
for inspiring an exploration into better integration of design and
|
78
|
+
development processes (which this project aims to address... over time).
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class GuidelinesController < ApplicationController
|
2
|
+
caches_page :index, :show
|
3
|
+
|
4
|
+
def index
|
5
|
+
render(:index, :locals => { :list => list })
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
render(item)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def basepath
|
15
|
+
@basepath ||= Rails.root.join('app', 'views', 'guidelines')
|
16
|
+
end
|
17
|
+
|
18
|
+
def item
|
19
|
+
@item ||= "guidelines/#{params[:id].to_s.downcase}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def list
|
23
|
+
@list ||= Dir.glob(File.join(basepath, "**", "*.html.*")).map { |fullpath| fullpath.sub(/#{basepath}\//, '').sub(/\.html.+$/, '') }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module GuidelinesHelper
|
2
|
+
class Builder
|
3
|
+
attr_reader :name, :template, :examples
|
4
|
+
|
5
|
+
def initialize(name, template, proc)
|
6
|
+
@name, @template, @proc = name, template, proc
|
7
|
+
@examples = []
|
8
|
+
|
9
|
+
proc.call(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
@examples.join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def example(&block)
|
17
|
+
@examples << decorate(template.capture(GuidelinesHelper::Example.new(example_id), &block)) ; nil
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def decorate(html)
|
23
|
+
fragment = Nokogiri::HTML::DocumentFragment.parse(html)
|
24
|
+
fragment.css('*').each do |node|
|
25
|
+
node.set_attribute('data-guideline-example', example_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
fragment.to_html
|
29
|
+
end
|
30
|
+
|
31
|
+
def example_id
|
32
|
+
(@examples.length + 1).to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def safe_name
|
36
|
+
name.gsub(/[#\/]/, '_')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/config/routes.rb
ADDED
data/guidelines.gems
ADDED
data/guidelines.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "guidelines/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "guidelines"
|
7
|
+
s.version = Guidelines::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Corey Innis"]
|
10
|
+
s.email = ["corey@coolerator.net"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Adds guidelines to a Rails application.}
|
13
|
+
s.description = %q{To use guidelines in your application, simply add views in app/views/guidelines (nested paths are allowed).}
|
14
|
+
|
15
|
+
s.rubyforge_project = "guidelines"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/guidelines.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guidelines
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Corey Innis
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-06 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: To use guidelines in your application, simply add views in app/views/guidelines (nested paths are allowed).
|
23
|
+
email:
|
24
|
+
- corey@coolerator.net
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- .rvmrc
|
34
|
+
- .wiprc
|
35
|
+
- .wiprc_fn
|
36
|
+
- Gemfile
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- app/controllers/guidelines_controller.rb
|
40
|
+
- app/helpers/guidelines_helper.rb
|
41
|
+
- app/helpers/guidelines_helper/builder.rb
|
42
|
+
- app/helpers/guidelines_helper/example.rb
|
43
|
+
- app/views/guidelines/index.html.erb
|
44
|
+
- config/locales/en.yml
|
45
|
+
- config/routes.rb
|
46
|
+
- guidelines.gems
|
47
|
+
- guidelines.gemspec
|
48
|
+
- lib/guidelines.rb
|
49
|
+
- lib/guidelines/rails.rb
|
50
|
+
- lib/guidelines/rails/engine.rb
|
51
|
+
- lib/guidelines/version.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: ""
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project: guidelines
|
82
|
+
rubygems_version: 1.6.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Adds guidelines to a Rails application.
|
86
|
+
test_files: []
|
87
|
+
|