pattern_library 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +11 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/pattern_library/application.js +13 -0
  6. data/app/assets/javascripts/pattern_library/patterns.js +41 -0
  7. data/app/assets/stylesheets/pattern_library/application.css +15 -0
  8. data/app/assets/stylesheets/pattern_library/patterns.css +55 -0
  9. data/app/controllers/pattern_library/application_controller.rb +4 -0
  10. data/app/controllers/pattern_library/patterns_controller.rb +60 -0
  11. data/app/helpers/pattern_library/application_helper.rb +4 -0
  12. data/app/helpers/pattern_library/patterns_helper.rb +4 -0
  13. data/app/models/pattern_library/pattern.rb +9 -0
  14. data/app/views/pattern_library/patterns/_form.html.erb +18 -0
  15. data/app/views/pattern_library/patterns/_pattern.html.erb +24 -0
  16. data/app/views/pattern_library/patterns/edit.html.erb +3 -0
  17. data/app/views/pattern_library/patterns/index.html.erb +11 -0
  18. data/app/views/pattern_library/patterns/new.html.erb +3 -0
  19. data/app/views/pattern_library/patterns/show.html.erb +13 -0
  20. data/config/routes.rb +5 -0
  21. data/db/migrate/20140527235054_create_pattern_library_patterns.rb +12 -0
  22. data/db/seeds.rb +65 -0
  23. data/lib/pattern_library.rb +4 -0
  24. data/lib/pattern_library/engine.rb +5 -0
  25. data/lib/pattern_library/version.rb +3 -0
  26. data/lib/tasks/pattern_library_tasks.rake +4 -0
  27. data/test/controllers/pattern_library/patterns_controller_test.rb +10 -0
  28. data/test/dummy/README.rdoc +28 -0
  29. data/test/dummy/Rakefile +6 -0
  30. data/test/dummy/app/assets/javascripts/application.js +15 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +31 -0
  32. data/test/dummy/app/controllers/application_controller.rb +5 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/bin/bundle +3 -0
  36. data/test/dummy/bin/rails +4 -0
  37. data/test/dummy/bin/rake +4 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/config/application.rb +23 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +37 -0
  44. data/test/dummy/config/environments/production.rb +83 -0
  45. data/test/dummy/config/environments/test.rb +39 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/test/dummy/config/initializers/inflections.rb +16 -0
  50. data/test/dummy/config/initializers/mime_types.rb +4 -0
  51. data/test/dummy/config/initializers/session_store.rb +3 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/dummy/config/locales/en.yml +23 -0
  54. data/test/dummy/config/routes.rb +4 -0
  55. data/test/dummy/config/secrets.yml +22 -0
  56. data/test/dummy/db/development.sqlite3 +0 -0
  57. data/test/dummy/db/production.sqlite3 +0 -0
  58. data/test/dummy/db/schema.rb +25 -0
  59. data/test/dummy/db/seeds.rb +1 -0
  60. data/test/dummy/db/test.sqlite3 +0 -0
  61. data/test/dummy/log/development.log +8309 -0
  62. data/test/dummy/log/test.log +68 -0
  63. data/test/dummy/public/404.html +67 -0
  64. data/test/dummy/public/422.html +67 -0
  65. data/test/dummy/public/500.html +66 -0
  66. data/test/dummy/public/favicon.ico +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sass/4f73e2af3062ca881016df4ebd14d864ca943441/patterns.css.scssc +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/006a59d1a303dda3eb9f0546e2415d2c +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/07d4e33471c9154d1159c617d7a0f5d0 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/2985c925c31a296a008e59a6c82608c6 +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/2c1ce725ddfe3b7e607e88817f46aaed +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/4712ad00829fe4b2ac538364a5127b43 +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/4fabea8e55d27d7d03be13022b85b290 +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/6763e036e26a439067cccc0771c83593 +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/6d8bd970f51a34b98023e6d3d6e8c2a0 +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/6e8b96e09bc757dc2d1b9bfb8c597f2d +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/77a1b70650a56776dd48452fbd25bf22 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/77feb62dbfe44ffa6f745ed1b34153c8 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/8bf1e05f6420dbe55c5fdc3ff4863fec +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/9a5b989b58e19ea3833357c3037110c6 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/9d6fd92e466f4cbe9777ca68cc992c4c +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/be0e3a180f103c1d8c15f145e30d92ae +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/c208e2bff5591dbbd84df3ef69668a34 +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/c3268eb21d6e6fd69ed061de6f6a16d8 +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/c98b829e71d98386ef302548342033eb +0 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  90. data/test/dummy/tmp/cache/assets/development/sprockets/d4e160f708d54e3129435fadb12645c2 +0 -0
  91. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  92. data/test/dummy/tmp/cache/assets/development/sprockets/e3bf10301fa3e1b9085e2e8bf8b2bac3 +0 -0
  93. data/test/dummy/tmp/cache/assets/development/sprockets/f576827684a0dd5c7db12b51d1f47f65 +0 -0
  94. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/07d4e33471c9154d1159c617d7a0f5d0 +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  97. data/test/dummy/tmp/cache/assets/test/sprockets/2985c925c31a296a008e59a6c82608c6 +0 -0
  98. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/6d8bd970f51a34b98023e6d3d6e8c2a0 +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/6e8b96e09bc757dc2d1b9bfb8c597f2d +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/77feb62dbfe44ffa6f745ed1b34153c8 +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/9a5b989b58e19ea3833357c3037110c6 +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/be0e3a180f103c1d8c15f145e30d92ae +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/c3268eb21d6e6fd69ed061de6f6a16d8 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/c98b829e71d98386ef302548342033eb +0 -0
  107. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  108. data/test/dummy/tmp/cache/assets/test/sprockets/d4e160f708d54e3129435fadb12645c2 +0 -0
  109. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  110. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  111. data/test/dummy/tmp/restart.txt +0 -0
  112. data/test/fixtures/pattern_library/patterns.yml +11 -0
  113. data/test/helpers/pattern_library/patterns_helper_test.rb +6 -0
  114. data/test/integration/navigation_test.rb +10 -0
  115. data/test/models/pattern_library/pattern_test.rb +9 -0
  116. data/test/pattern_library_test.rb +7 -0
  117. data/test/test_helper.rb +15 -0
  118. metadata +293 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bbb8f45476b076d9e06304257cd93dc18008b05e
4
+ data.tar.gz: 8332fe702f3143838f76ad70cf563c1177a6d793
5
+ SHA512:
6
+ metadata.gz: b3bffb790f7451b3465a8db89173be102234f5a991d37e2d9934531ad6118e591eee89fbefbbdc779b2ac3913d6fd11ac1b2c9c25da071321003ded8ed5e4b5d
7
+ data.tar.gz: f40f030dbb7204dc7d305d2b79ee8b6a0e1ad24d8047900347b0dbe17a2f0cfc975b88be13d69fdf97d28fbec3fe260b5c97ce6cb471c787545a098375e55a76
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ = PatternLibrary
2
+
3
+ This project rocks and uses MIT-LICENSE.
4
+
5
+ == Usage
6
+
7
+ 1. require gem
8
+ 1. mount engine in routes.rb: "mount PatternLibrary::Engine => "/pattern_library""
9
+ 1. copy migrations "rake pattern_library:install:migrations"
10
+ 1. load seeds: "PatternLibrary::Engine.load_seed"
11
+ 1. load css: *= require pattern_library/patterns
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'PatternLibrary'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,41 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+
4
+ $(function() {
5
+ $('#pl-patterns .pl-pattern').each(function() {
6
+ var $this = $(this);
7
+ $this.find('.pl-snippet-styled > *').each(function() {
8
+ var styles = css($(this));
9
+ $(this).find('*').each(function() {
10
+ styles = styles.concat(css($(this)));
11
+ });
12
+ $this.find('.pl-pattern-css').text(prettyPrintArray(styles));
13
+ });
14
+ });
15
+ });
16
+
17
+ function css(a) {
18
+ var sheets = document.styleSheets, o = [];
19
+ for (var i in sheets) {
20
+ var rules = sheets[i].rules || sheets[i].cssRules;
21
+ for (var r in rules) {
22
+ if (a.is(rules[r].selectorText)) {
23
+ o.push(rules[r].cssText);
24
+ }
25
+ }
26
+ }
27
+ if (a.attr('style')) {
28
+ o.push("Inline { " + a.attr('style') + " }");
29
+ }
30
+ return o;
31
+ }
32
+
33
+ function prettyPrintArray(styles) {
34
+ return $.map(styles, function(rule) {
35
+ rule = rule.replace(/\{\s*/g, '{\n ');
36
+ rule = rule.replace(/;\s*/g, ';\n ');
37
+ rule = rule.replace(/([^;\s])\s*\}/g, '$1;\n}');
38
+ rule = rule.replace(/^\s+\}/gm, '}');
39
+ return rule;
40
+ }).join('\n');
41
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,55 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ #pl-patterns {
7
+ border-top: 1px solid #333 !important;
8
+ }
9
+
10
+ #pl-patterns > .pl-pattern {
11
+ margin: 1em !important;
12
+ padding: 10px !important;
13
+ border-bottom: 1px solid #333 !important;
14
+ }
15
+
16
+ #pl-patterns > .pl-pattern .pl-pattern-html {
17
+ float: left;
18
+ width: 60%;
19
+ overflow: auto;
20
+ }
21
+
22
+ #pl-patterns > .pl-pattern .pl-pattern-css {
23
+ float: left;
24
+ width: 40%;
25
+ overflow: auto;
26
+ padding-left: 10px;
27
+ box-sizing: border-box;
28
+ }
29
+
30
+ #pl-patterns > .pl-pattern .pl-snippet-styled {
31
+ padding: 0 !important;
32
+ margin: 0 !important;
33
+ border: 1px solid #ccc !important;
34
+ position: relative !important;
35
+ overflow: hidden !important;
36
+ }
37
+
38
+ #pl-patterns > .pl-pattern .pl-actions {
39
+ clear: both;
40
+ }
41
+
42
+ #pl-patterns > .pl-pattern .pl-actions > * {
43
+ display: inline-block !important;
44
+ margin-top: 10px !important;
45
+ }
46
+
47
+ #pl-pattern-form .field, #pl-pattern-form .actions {
48
+ margin: 1em !important;
49
+ }
50
+
51
+ #pl-pattern-form label {
52
+ width: 125px !important;
53
+ display: inline-block !important;
54
+ vertical-align: top !important;
55
+ }
@@ -0,0 +1,4 @@
1
+ module PatternLibrary
2
+ class ApplicationController < ::ApplicationController
3
+ end
4
+ end
@@ -0,0 +1,60 @@
1
+ require_dependency "pattern_library/application_controller"
2
+
3
+ module PatternLibrary
4
+ class PatternsController < ApplicationController
5
+ before_action :find_pattern, only: [:show, :edit, :update, :destroy]
6
+ before_action :protect_builtin, only: [:edit, :update, :destroy]
7
+
8
+ def index
9
+ @patterns = Pattern.all
10
+ end
11
+
12
+ def show
13
+ end
14
+
15
+ def new
16
+ @pattern = Pattern.new(order: Pattern.count)
17
+ end
18
+
19
+ def create
20
+ @pattern = Pattern.new pattern_params
21
+ if @pattern.save
22
+ redirect_to patterns_path, notice: 'Pattern created successfully'
23
+ else
24
+ flash.now[:alert] = @pattern.errors.full_messages.join('. ')
25
+ render :new
26
+ end
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ if @pattern.update_attributes pattern_params
34
+ redirect_to patterns_path, notice: 'Pattern updated successfully'
35
+ else
36
+ flash.now[:alert] = @pattern.errors.full_messages.join('. ')
37
+ render :edit
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @pattern.destroy
43
+ redirect_to patterns_path, notice: 'Pattern deleted'
44
+ end
45
+
46
+ private
47
+
48
+ def find_pattern
49
+ @pattern = Pattern.find params[:id]
50
+ end
51
+
52
+ def protect_builtin
53
+ redirect_to patterns_path unless @pattern.custom?
54
+ end
55
+
56
+ def pattern_params
57
+ params.require(:pattern).permit :snippet, :usage, :order
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,4 @@
1
+ module PatternLibrary
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PatternLibrary
2
+ module PatternsHelper
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module PatternLibrary
2
+ class Pattern < ActiveRecord::Base
3
+
4
+ default_scope { order :order }
5
+
6
+ validates_presence_of :snippet
7
+ validates_numericality_of :order, only_integer: true, greater_than_or_equal_to: 0
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ <div id="pl-pattern-form">
2
+ <%= form_for @pattern do |f| %>
3
+ <div class="field">
4
+ <%= f.label :snippet %>
5
+ <%= f.text_area :snippet, rows: 10, cols: 100 %>
6
+ </div>
7
+ <div class="field">
8
+ <%= f.label :usage, 'Usage (optional)' %>
9
+ <%= f.text_area :usage, rows: 10, cols: 100 %>
10
+ </div>
11
+ <%= f.hidden_field :order %>
12
+ <div class="actions">
13
+ <%= f.submit %>
14
+ |
15
+ <%= link_to 'Cancel', patterns_path %>
16
+ </div>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,24 @@
1
+ <div class="pl-pattern">
2
+ <div class="pl-pattern-html">
3
+ <pre class="pl-snippet"><%= pattern.snippet %></pre>
4
+ <div class="pl-snippet-styled">
5
+ <%= pattern.snippet.html_safe %>
6
+ </div>
7
+ </div>
8
+ <pre class="pl-pattern-css">
9
+ </pre>
10
+ <div class="pl-actions">
11
+ <% if pattern.usage.present? && !current_page?(pattern_path(pattern)) %>
12
+ <%= link_to 'Usage details', pattern_path(pattern) %>
13
+ <% if pattern.custom? %>
14
+ |
15
+ <% end %>
16
+ <% end %>
17
+ <% if pattern.custom? %>
18
+ <%= link_to 'Edit Pattern', edit_pattern_path(pattern) %> |
19
+ <%= form_for pattern, method: :delete do |f| %>
20
+ <%= f.submit 'Delete Pattern' %>
21
+ <% end %>
22
+ <% end %>
23
+ </div>
24
+ </div>
@@ -0,0 +1,3 @@
1
+ <h1>Edit Pattern</h1>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1,11 @@
1
+ <h1>Patterns</h1>
2
+
3
+ <div id="pl-patterns">
4
+ <% @patterns.each do |pattern| %>
5
+ <%= render pattern %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <div id="pl-actions">
10
+ <p><%= link_to 'Create Pattern', new_pattern_path %></p>
11
+ </div>
@@ -0,0 +1,3 @@
1
+ <h1>Create Pattern</h1>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1,13 @@
1
+ <h1>Pattern</h1>
2
+
3
+ <div id="pl-patterns">
4
+ <%= render @pattern %>
5
+ <h2>Usage</h2>
6
+ <div class="pl-pattern">
7
+ <%= @pattern.usage %>
8
+ </div>
9
+ </div>
10
+
11
+ <div id="pl-actions">
12
+ <p><%= link_to 'Back to list', patterns_path %></p>
13
+ </div>
@@ -0,0 +1,5 @@
1
+ PatternLibrary::Engine.routes.draw do
2
+ resources :patterns
3
+
4
+ root to: 'patterns#index'
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePatternLibraryPatterns < ActiveRecord::Migration
2
+ def change
3
+ create_table :pattern_library_patterns do |t|
4
+ t.string :snippet, null: false
5
+ t.text :usage, default: ''
6
+ t.integer :order, default: 0
7
+ t.boolean :custom, default: true
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,65 @@
1
+ PatternLibrary::Pattern.where(custom: false).delete_all
2
+
3
+ order = -1
4
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h1>Header One</h1>'
5
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h2>Header Two</h2>'
6
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h3>Header Three</h3>'
7
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h4>Header Four</h4>'
8
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h5>Header Five</h5>'
9
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<h6>Header Six</h6>'
10
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<p>Paragraph Text</p>'
11
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<p><a href="#">Link text</a></p>'
12
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<p><q>Inline Quotation</q></p>'
13
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<p><em>Emphasized</em> Paragraph Text</p>'
14
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: '<p><strong>Strong</strong> Paragraph Text</p>'
15
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<TABLE.strip_heredoc
16
+ <table>
17
+ <thead>
18
+ <tr>
19
+ <th>Header</th>
20
+ <th>Columns</th>
21
+ </tr>
22
+ </thead>
23
+ <tbody>
24
+ <tr>
25
+ <td>Body</td>
26
+ <td>Column</td>
27
+ </tr>
28
+ <tr>
29
+ <td>Body</td>
30
+ <td>Column</td>
31
+ </tr>
32
+ </tbody>
33
+ </table>
34
+ TABLE
35
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<UL.strip_heredoc
36
+ <ul>
37
+ <li>Unordered</li>
38
+ <li>List</li>
39
+ </ul>
40
+ UL
41
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<OL.strip_heredoc
42
+ <ol>
43
+ <li>Ordered</li>
44
+ <li>List</li>
45
+ </ol>
46
+ OL
47
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<DL.strip_heredoc
48
+ <dl>
49
+ <dt>Definition Term 1</dt>
50
+ <dd>Definition Description 1</dd>
51
+ <dt>Definition Term 2</dt>
52
+ <dd>Definition Description 2</dd>
53
+ </dl>
54
+ DL
55
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<BQ.strip_heredoc
56
+ <blockquote>
57
+ Better to remain silent and be thought a fool than to speak out and remove all doubt.
58
+ </blockquote>
59
+ BQ
60
+ PatternLibrary::Pattern.create order: order += 1, custom: false, snippet: <<FIG.strip_heredoc
61
+ <figure>
62
+ <img src="http://f.cl.ly/items/1x3y251R0W0m1u02421z/Image%202014-02-21%20at%204.50.36%20PM.png" alt="high usage">
63
+ <figcaption>Figure wrapping an image with caption</figcaption>
64
+ </figure>
65
+ FIG