express_admin 1.7.5 → 1.7.7

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 (177) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/express_admin/components/command_button.js.coffee +25 -0
  3. data/app/assets/stylesheets/express_admin/components/_command_button.sass +6 -1
  4. data/app/assets/stylesheets/express_admin/globals/_variables.sass +2 -0
  5. data/app/assets/stylesheets/express_admin/plugins/_select2.sass +3 -0
  6. data/app/assets/stylesheets/express_admin/screen.sass +0 -2
  7. data/app/assets/stylesheets/express_admin/shared/_tables.sass +2 -0
  8. data/app/components/express_admin/command_button.rb +9 -3
  9. data/app/components/express_admin/definition_table.rb +1 -1
  10. data/app/components/express_admin/smart_table.rb +6 -0
  11. data/app/views/layouts/devise.html.erb +19 -0
  12. data/config/initializers/postgresql_trigram.rb +13 -0
  13. data/db/migrate/20150928044202_install_trigram.rb +18 -0
  14. data/lib/express_admin/engine.rb +4 -2
  15. data/lib/express_admin/search.rb +51 -0
  16. data/lib/express_admin/standard_actions.rb +18 -5
  17. data/lib/express_admin/version.rb +1 -1
  18. data/test/dummy/db/test.sqlite3 +0 -0
  19. data/test/dummy/test/components/command_button_test.rb +2 -2
  20. metadata +22 -160
  21. data/app/assets/stylesheets/express_admin/shared/_buttons.sass +0 -3
  22. data/app/assets/stylesheets/express_admin/shared/_tabs.sass +0 -25
  23. data/vendor/gems/express_templates/CHANGELOG.md +0 -12
  24. data/vendor/gems/express_templates/Gemfile +0 -16
  25. data/vendor/gems/express_templates/LICENSE +0 -21
  26. data/vendor/gems/express_templates/README.md +0 -133
  27. data/vendor/gems/express_templates/Rakefile +0 -32
  28. data/vendor/gems/express_templates/express_templates.gemspec +0 -32
  29. data/vendor/gems/express_templates/lib/arbre/patches.rb +0 -76
  30. data/vendor/gems/express_templates/lib/core_extensions/proc.rb +0 -103
  31. data/vendor/gems/express_templates/lib/core_extensions/string.rb +0 -25
  32. data/vendor/gems/express_templates/lib/express_templates/compiler.rb +0 -22
  33. data/vendor/gems/express_templates/lib/express_templates/components/all.rb +0 -28
  34. data/vendor/gems/express_templates/lib/express_templates/components/base.rb +0 -156
  35. data/vendor/gems/express_templates/lib/express_templates/components/capabilities/resourceful.rb +0 -213
  36. data/vendor/gems/express_templates/lib/express_templates/components/configurable.rb +0 -181
  37. data/vendor/gems/express_templates/lib/express_templates/components/container.rb +0 -45
  38. data/vendor/gems/express_templates/lib/express_templates/components/forms/basic_fields.rb +0 -52
  39. data/vendor/gems/express_templates/lib/express_templates/components/forms/checkbox.rb +0 -37
  40. data/vendor/gems/express_templates/lib/express_templates/components/forms/express_form.rb +0 -48
  41. data/vendor/gems/express_templates/lib/express_templates/components/forms/form_component.rb +0 -88
  42. data/vendor/gems/express_templates/lib/express_templates/components/forms/option_support.rb +0 -69
  43. data/vendor/gems/express_templates/lib/express_templates/components/forms/radio.rb +0 -65
  44. data/vendor/gems/express_templates/lib/express_templates/components/forms/select.rb +0 -126
  45. data/vendor/gems/express_templates/lib/express_templates/components/forms/select_collection.rb +0 -45
  46. data/vendor/gems/express_templates/lib/express_templates/components/forms/submit.rb +0 -30
  47. data/vendor/gems/express_templates/lib/express_templates/components/forms.rb +0 -16
  48. data/vendor/gems/express_templates/lib/express_templates/components/tree_for.rb +0 -88
  49. data/vendor/gems/express_templates/lib/express_templates/components.rb +0 -11
  50. data/vendor/gems/express_templates/lib/express_templates/indenter.rb +0 -47
  51. data/vendor/gems/express_templates/lib/express_templates/interpolator.rb +0 -36
  52. data/vendor/gems/express_templates/lib/express_templates/renderer.rb +0 -9
  53. data/vendor/gems/express_templates/lib/express_templates/template/handler.rb +0 -32
  54. data/vendor/gems/express_templates/lib/express_templates/version.rb +0 -3
  55. data/vendor/gems/express_templates/lib/express_templates.rb +0 -18
  56. data/vendor/gems/express_templates/lib/tasks/express_templates.rake +0 -4
  57. data/vendor/gems/express_templates/test/compiler_test.rb +0 -9
  58. data/vendor/gems/express_templates/test/components/base_test.rb +0 -67
  59. data/vendor/gems/express_templates/test/components/capabilities/resourceful_test.rb +0 -63
  60. data/vendor/gems/express_templates/test/components/configurable_test.rb +0 -140
  61. data/vendor/gems/express_templates/test/components/forms/basic_fields_test.rb +0 -158
  62. data/vendor/gems/express_templates/test/components/forms/checkbox_test.rb +0 -51
  63. data/vendor/gems/express_templates/test/components/forms/express_form_test.rb +0 -62
  64. data/vendor/gems/express_templates/test/components/forms/radio_test.rb +0 -112
  65. data/vendor/gems/express_templates/test/components/forms/select_test.rb +0 -129
  66. data/vendor/gems/express_templates/test/components/forms/submit_test.rb +0 -36
  67. data/vendor/gems/express_templates/test/components/tree_for_test.rb +0 -70
  68. data/vendor/gems/express_templates/test/core_extensions/proc_test.rb +0 -90
  69. data/vendor/gems/express_templates/test/core_extensions/string_test.rb +0 -20
  70. data/vendor/gems/express_templates/test/dummy/Rakefile +0 -6
  71. data/vendor/gems/express_templates/test/dummy/app/assets/javascripts/application.js +0 -13
  72. data/vendor/gems/express_templates/test/dummy/app/assets/stylesheets/application.css +0 -15
  73. data/vendor/gems/express_templates/test/dummy/app/controllers/application_controller.rb +0 -5
  74. data/vendor/gems/express_templates/test/dummy/app/controllers/hello_controller.rb +0 -5
  75. data/vendor/gems/express_templates/test/dummy/app/helpers/application_helper.rb +0 -2
  76. data/vendor/gems/express_templates/test/dummy/app/views/hello/show.html.et +0 -6
  77. data/vendor/gems/express_templates/test/dummy/app/views/layouts/application.html.et +0 -15
  78. data/vendor/gems/express_templates/test/dummy/bin/bundle +0 -3
  79. data/vendor/gems/express_templates/test/dummy/bin/rails +0 -4
  80. data/vendor/gems/express_templates/test/dummy/bin/rake +0 -4
  81. data/vendor/gems/express_templates/test/dummy/config/application.rb +0 -26
  82. data/vendor/gems/express_templates/test/dummy/config/boot.rb +0 -5
  83. data/vendor/gems/express_templates/test/dummy/config/environment.rb +0 -5
  84. data/vendor/gems/express_templates/test/dummy/config/environments/development.rb +0 -37
  85. data/vendor/gems/express_templates/test/dummy/config/environments/production.rb +0 -82
  86. data/vendor/gems/express_templates/test/dummy/config/environments/test.rb +0 -40
  87. data/vendor/gems/express_templates/test/dummy/config/initializers/assets.rb +0 -8
  88. data/vendor/gems/express_templates/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  89. data/vendor/gems/express_templates/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  90. data/vendor/gems/express_templates/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  91. data/vendor/gems/express_templates/test/dummy/config/initializers/inflections.rb +0 -16
  92. data/vendor/gems/express_templates/test/dummy/config/initializers/mime_types.rb +0 -4
  93. data/vendor/gems/express_templates/test/dummy/config/initializers/session_store.rb +0 -3
  94. data/vendor/gems/express_templates/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  95. data/vendor/gems/express_templates/test/dummy/config/locales/en.yml +0 -23
  96. data/vendor/gems/express_templates/test/dummy/config/routes.rb +0 -4
  97. data/vendor/gems/express_templates/test/dummy/config/secrets.yml +0 -22
  98. data/vendor/gems/express_templates/test/dummy/config.ru +0 -4
  99. data/vendor/gems/express_templates/test/dummy/public/404.html +0 -67
  100. data/vendor/gems/express_templates/test/dummy/public/422.html +0 -67
  101. data/vendor/gems/express_templates/test/dummy/public/500.html +0 -66
  102. data/vendor/gems/express_templates/test/dummy/public/favicon.ico +0 -0
  103. data/vendor/gems/express_templates/test/dummy/test/controllers/hello_controller_test.rb +0 -14
  104. data/vendor/gems/express_templates/test/dummy/test/helpers/hello_helper_test.rb +0 -4
  105. data/vendor/gems/express_templates/test/express_templates_test.rb +0 -23
  106. data/vendor/gems/express_templates/test/handler_test.rb +0 -148
  107. data/vendor/gems/express_templates/test/indenter_test.rb +0 -27
  108. data/vendor/gems/express_templates/test/interpolator_test.rb +0 -80
  109. data/vendor/gems/express_templates/test/performance_test.rb +0 -97
  110. data/vendor/gems/express_templates/test/test_helper.rb +0 -178
  111. data/vendor/gems/foundation_apps_styles/Gemfile +0 -4
  112. data/vendor/gems/foundation_apps_styles/LICENSE.txt +0 -21
  113. data/vendor/gems/foundation_apps_styles/README.md +0 -41
  114. data/vendor/gems/foundation_apps_styles/Rakefile +0 -13
  115. data/vendor/gems/foundation_apps_styles/bin/console +0 -14
  116. data/vendor/gems/foundation_apps_styles/bin/setup +0 -7
  117. data/vendor/gems/foundation_apps_styles/foundation_apps_styles.gemspec +0 -24
  118. data/vendor/gems/foundation_apps_styles/lib/foundation_apps_styles/version.rb +0 -3
  119. data/vendor/gems/foundation_apps_styles/lib/foundation_apps_styles.rb +0 -6
  120. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/account.svg +0 -44
  121. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/action.svg +0 -38
  122. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/ban.svg +0 -17
  123. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/bell.svg +0 -22
  124. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/bookmark.svg +0 -14
  125. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/cart.svg +0 -35
  126. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/chevron.svg +0 -28
  127. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/circle-check.svg +0 -25
  128. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/circle-x.svg +0 -25
  129. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/cog.svg +0 -17
  130. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/comment-square.svg +0 -14
  131. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/dashboard.svg +0 -38
  132. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/document.svg +0 -28
  133. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/envelope.svg +0 -44
  134. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/flag.svg +0 -24
  135. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/home.svg +0 -28
  136. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/lock.svg +0 -55
  137. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/magnifying-glass.svg +0 -26
  138. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/person.svg +0 -62
  139. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/reload.svg +0 -19
  140. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/share-boxed.svg +0 -17
  141. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/star.svg +0 -14
  142. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/thumb.svg +0 -38
  143. data/vendor/gems/foundation_apps_styles/vendor/assets/iconic/zoom.svg +0 -56
  144. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/_global.scss +0 -131
  145. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/_includes.scss +0 -33
  146. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/_settings.scss +0 -614
  147. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_accordion.scss +0 -72
  148. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_action-sheet.scss +0 -265
  149. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_block-list.scss +0 -360
  150. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_button-group.scss +0 -197
  151. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_button.scss +0 -205
  152. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_card.scss +0 -93
  153. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_extras.scss +0 -54
  154. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_forms.scss +0 -460
  155. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_grid.scss +0 -422
  156. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_iconic.scss +0 -95
  157. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_label.scss +0 -134
  158. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_list.scss +0 -19
  159. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_menu-bar.scss +0 -382
  160. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_modal.scss +0 -129
  161. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_motion.scss +0 -525
  162. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_notification.scss +0 -207
  163. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_off-canvas.scss +0 -169
  164. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_panel.scss +0 -134
  165. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_popup.scss +0 -68
  166. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_switch.scss +0 -134
  167. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_tabs.scss +0 -100
  168. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_title-bar.scss +0 -135
  169. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_typography.scss +0 -345
  170. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/components/_utilities.scss +0 -160
  171. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/foundation-apps.css +0 -6146
  172. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/foundation.scss +0 -50
  173. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/helpers/_breakpoints.scss +0 -154
  174. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/helpers/_functions.scss +0 -343
  175. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/helpers/_images.scss +0 -19
  176. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/helpers/_mixins.scss +0 -123
  177. data/vendor/gems/foundation_apps_styles/vendor/assets/stylesheets/vendor/_normalize.scss +0 -424
@@ -1,16 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Declare your gem's dependencies in express_templates.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
6
- gemspec
7
-
8
- # Declare any dependencies that are still in development here instead of in
9
- # your gemspec. These might include edge Rails or gems from your path or
10
- # Git. Remember to move these dependencies to your gemspec before releasing
11
- # your gem to rubygems.org.
12
-
13
- # To use debugger
14
- # gem 'debugger'
15
- gem 'pry-byebug'
16
- gem 'minitest-reporters'
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 ÆLOGICA | Build it better here.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,133 +0,0 @@
1
- # ExpressTemplates
2
-
3
- Provides a DSL for HTML templates using a declarative style of Ruby as an alternative to Erb or HAML.
4
-
5
- Although originally we implemented our own DSL and used a code generation approach,
6
- this gem now uses [ActiveAdmin's arbre](https://github.com/activeadmin/arbre). Arbre is widely
7
- used as part of ActiveAdmin, has a long history and many contributors and is conceptually much simpler.
8
-
9
- ## Usage
10
-
11
- Add this to your gemfile:
12
-
13
- ```ruby
14
- gem 'express_templates'
15
- ```
16
-
17
- Rename your application.html.erb to application.html.et.
18
-
19
- Change your template to look like this.
20
-
21
- ```ruby
22
- html(lang: "en") {
23
- head {
24
- meta charset: 'utf-8'
25
- meta name: 'viewport', content: "width=device-width, initial-scale=1.0"
26
- title {
27
- content_for(:title)
28
- }
29
- stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
30
- csrf_meta_tags
31
- }
32
- body {
33
- current_arbre_element.add_child yield
34
- javascript_include_tag "application"
35
- }
36
- }
37
- ```
38
-
39
- Everything should work as you would expect.
40
-
41
- Set your editor syntax for .et files to Ruby.
42
-
43
- You can now utilize components which are found with documentation and examples in <tt>ExpressTemplates::Components</tt>.
44
-
45
- Components are the real strength of both arbre and express_templates.
46
-
47
- express_templates now *is* arbre + some components + some conventions. ExpressTemplates::Components::Base provides a little syntactic sugar in the form of the emits class method.
48
-
49
- In terms of conventions, we use brace blocks { } to indicate html structure and do/end blocks to indicate control flow.
50
-
51
- Control flow should only be used in Components. This is currently not enforced but it will be in the future.
52
-
53
- The purpose of express_templates is to provide a foundation for a library of reusable UX components which we can enhance for drag-and-drop style UX construction and template editing.
54
-
55
-
56
- ## Block Structure
57
-
58
- ExpressTemplates use Ruby's block structure and execution order to indicate parent-child relationships and to build the tree structure that ultimately results in nodes in the DOM.
59
-
60
- Example:
61
-
62
- ```ruby
63
- ul {
64
- li { "one" }
65
- li "two"
66
- li %Q(#{@three})
67
- }
68
- ```
69
-
70
- Let us suppose that an @three variable exists in the view context with the value "three". This would yield the following markup:
71
-
72
- ```html
73
- <ul>
74
- <li>one</li>
75
- <li>two</li>
76
- <li>three</li>
77
- </ul>
78
- ```
79
-
80
- ## Components
81
-
82
- Given the constraint that logic must not go in the template, where does one put it? The answer is we make a component!
83
-
84
- ExpressTemplates provide a framework for construction of components by encapsulating common logic patterns found in view code into Capabilities which Components may include. These Capabilities form a DSL which allows Components to be built in a declarative fashion. This makes them "low-cost" entities to construct in terms of developer time.
85
-
86
- A common need is for a list items such as in the above example to be generated from a collection or array of data. Let us suppose we expect the view context to have:
87
-
88
- ```ruby
89
- @list = %w(one two three)
90
- ```
91
-
92
- We can make a simple component like so:
93
-
94
- ```ruby
95
- class ListComponent < ExpressTemplates::Components::Base
96
- emits -> {
97
- ul {
98
- # assumes view provides list
99
- list.each do |item|
100
- li {
101
- item
102
- }
103
- end
104
- }
105
- }
106
- end
107
- ```
108
-
109
- This would be used in a view template just as if it were a tag, like so:
110
-
111
- ```ruby
112
- div(class: "active") {
113
- list_component
114
- }
115
- ```
116
-
117
- Now when the template renders, it will yield:
118
-
119
- ```html
120
- <div class="active">
121
- <ul>
122
- <li>one</li>
123
- <li>two</li>
124
- <li>three</li>
125
- </ul>
126
- </div>
127
- ```
128
-
129
- ## Background
130
-
131
- ExpressTemplates is a key part of the AppExpress platform at [appexpress.io](http://appexpress.io).
132
-
133
- This project rocks and uses MIT-LICENSE.
@@ -1,32 +0,0 @@
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 = 'ExpressTemplates'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
-
18
-
19
-
20
- Bundler::GemHelper.install_tasks
21
-
22
- require 'rake/testtask'
23
-
24
- Rake::TestTask.new(:test) do |t|
25
- t.libs << 'lib'
26
- t.libs << 'test'
27
- t.pattern = 'test/**/*_test.rb'
28
- t.verbose = false
29
- end
30
-
31
-
32
- task default: :test
@@ -1,32 +0,0 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
-
3
- # Maintain your gem's version:
4
- require "express_templates/version"
5
-
6
- # Describe your gem and declare its dependencies:
7
- Gem::Specification.new do |s|
8
- s.name = "express_templates"
9
- s.version = ExpressTemplates::VERSION
10
- s.authors = ["Steven Talcott Smith", "Eumir Gaspar"]
11
- s.email = ["steve@aelogica.com", "eumir@aelogica.com"]
12
- s.homepage = "https://github.com/aelogica/express_templates"
13
- s.summary = "Write HTML templates in declarative Ruby. Create reusable view components."
14
- s.description = "Replace Erb/HAML/Slim with ExpressTemplates and write templates in a declartive style of Ruby. With ExpressTemplates you may easily create a library of components for use across projects."
15
- s.license = "MIT"
16
-
17
- s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.md"]
18
- s.test_files = Dir["test/**/*"] - Dir["test/log/*", "test/tmp/*", "test/dummy/tmp/**/*", "test/dummy/log/*"]
19
-
20
- s.add_dependency "activesupport", "~> 4.2" # strictly speaking we only depend on active support
21
- s.add_dependency "parslet", "~> 1.6"
22
- s.add_dependency "arbre", "~> 1.0"
23
-
24
- s.add_development_dependency "rails", "~> 4.2"
25
- s.add_development_dependency "pry", "~> 0"
26
- s.add_development_dependency "erubis", "~> 2.7"
27
- s.add_development_dependency "haml", "~> 4.0"
28
- s.add_development_dependency "better_errors", "~> 2.0"
29
- s.add_development_dependency "binding_of_caller", "~> 0.7"
30
- s.add_development_dependency "pry-stack_explorer", "~> 0.4"
31
- s.add_development_dependency "minitest-line"
32
- end
@@ -1,76 +0,0 @@
1
- module Arbre
2
- class Context
3
- def resource
4
- helpers.resource
5
- end
6
- end
7
-
8
- class Element
9
-
10
- module BuilderMethods
11
-
12
- # we do not want to check the arity of the
13
- # block in express templates because components
14
- # are expected to be able to contain other components or template code
15
- # without use of a builder style syntax
16
- def build_tag(klass, *args, &block)
17
- tag = klass.new(arbre_context)
18
- tag.parent = current_arbre_element
19
-
20
- with_current_arbre_element tag do
21
- tag.build(*args, &block)
22
- end
23
-
24
- tag
25
- end
26
- end
27
-
28
- def possible_route_proxy(name)
29
- if helpers.controller.class.parent &&
30
- helpers.respond_to?(namespace = helpers.controller.class.parent.to_s.underscore)
31
- if (route_proxy = helpers.send(namespace)).respond_to?(name)
32
- return route_proxy
33
- end
34
- end
35
- return nil
36
- end
37
-
38
- # Implements the method lookup chain. When you call a method that
39
- # doesn't exist, we:
40
- #
41
- # 1. Try to call the method on the current DOM context
42
- # 2. Return an assigned variable of the same name
43
- # 3. Call the method on the helper object
44
- # 4. Call super
45
- #
46
- def method_missing(name, *args, &block)
47
- if current_arbre_element.respond_to?(name)
48
- current_arbre_element.send name, *args, &block
49
- elsif assigns && assigns.has_key?(name.to_sym)
50
- assigns[name.to_sym]
51
- elsif helpers.respond_to?(name)
52
- helper_method(name, *args, &block)
53
- elsif route_proxy = possible_route_proxy(name)
54
- route_proxy.send(name, *args, &block)
55
- else
56
- super
57
- end
58
- end
59
-
60
- # In order to not pollute our templates with helpers. prefixed
61
- # everywhere we want to try to distinguish helpers that are almost
62
- # always used as parameters to other methods such as path helpers
63
- # and not add them as elements
64
- def helper_method(name, *args, &block)
65
- if name.match /_path$/
66
- helpers.send(name, *args, &block)
67
- elsif (const_get([name, 'engine'].join('/').classify) rescue nil)
68
- helpers.send(name, *args, &block)
69
- else
70
- current_arbre_element.add_child helpers.send(name, *args, &block)
71
- end
72
- end
73
-
74
- end
75
-
76
- end
@@ -1,103 +0,0 @@
1
- require 'ripper'
2
- require 'pp'
3
- class Proc
4
-
5
- TLAMBEG = [:on_tlambeg, "{"]
6
- TLAMBDA = [:on_tlambda, "->"]
7
- LBRACE = [:on_lbrace, '{']
8
-
9
- TOKEN_PAIRS = {LBRACE => [:on_rbrace, '}'],
10
- [:on_kw, 'do'] => [:on_kw, 'end'],
11
- TLAMBDA => [:on_rbrace, '}']}
12
-
13
- # Make a best effort to provide the original source for a block
14
- # based on extracting a string from the file identified in
15
- # Proc#source_location using Ruby's tokenizer.
16
- #
17
- # This works for first block declared on a line in a source
18
- # file. If additional blocks are specified inside the first block
19
- # on the same line as the start of the block, only the outer-most
20
- # block declaration will be identified as a the block we want.
21
- #
22
- # If you require only the source of blocks-within-other-blocks, start them
23
- # on a new line as would be best practice for clarity and readability.
24
- def source
25
- @source ||= begin
26
- file, line_no = source_location
27
- raise "no file provided by source_location: #{self}" if file.nil?
28
- raise "no line number provided for source_location: #{self}" if line_no.nil?
29
- tokens = Ripper.lex File.read(file)
30
- tokens_on_line = tokens.select {|pos, lbl, str| pos[0].eql?(line_no) }
31
- starting_token = tokens_on_line.detect do |pos, lbl, str|
32
- TOKEN_PAIRS.keys.include?([lbl, str]) &&
33
- _actually_starting_a_proc?(tokens, [pos, lbl, str])
34
- end
35
- starting_token_type = [starting_token[1], starting_token[2]]
36
- ending_token_type = TOKEN_PAIRS[starting_token_type]
37
- source_str = ""
38
- remaining_tokens = tokens[tokens.index(starting_token)..-1]
39
- nesting = -1
40
- starting_nesting_token_types = if [TLAMBDA, LBRACE].include?(starting_token_type)
41
- [TLAMBDA, LBRACE]
42
- else
43
- [starting_token_type]
44
- end
45
-
46
- while token = remaining_tokens.shift
47
- token = [token[1], token[2]] # strip position
48
- source_str << token[1]
49
- nesting += 1 if starting_nesting_token_types.include? token
50
- is_ending_token = token.eql?(ending_token_type)
51
- break if is_ending_token && nesting.eql?(0)
52
- nesting -= 1 if is_ending_token
53
- end
54
- source_str
55
- end
56
- end
57
-
58
- def _actually_starting_a_proc?(tokens, tok)
59
- return true if tokens.index(tok).eql?(0)
60
- look_back = tokens.slice(0..tokens.index(tok)-1)
61
- look_back.pop if look_back.last.try(:[], 1).eql? :on_sp
62
- if [:on_tlambeg, :on_tlambda].include?(tok[1])
63
- true
64
- else
65
- ![:on_comma, :on_lparen, :on_label].include?(look_back.last.try(:[], 1))
66
- end
67
- end
68
-
69
- # Examines the source of a proc to extract the body by
70
- # removing the outermost block delimiters and any surrounding.
71
- # whitespace.
72
- #
73
- # Raises exception if the block takes arguments.
74
- #
75
- def source_body
76
- raise "Cannot extract proc body on non-zero arity" unless arity.eql?(0)
77
- tokens = Ripper.lex source
78
- body_start_idx = 2
79
- body_end_idx = -1
80
- if tokens[0][1].eql?(:on_tlambda)
81
- body_start_idx = tokens.index(tokens.detect { |t| t[1].eql?(:on_tlambeg) }) + 1
82
- end
83
- body_tokens = tokens[body_start_idx..-1]
84
-
85
- body_tokens.pop # ending token of proc
86
- # remove trailing whitespace
87
- whitespace = [:on_sp, :on_nl, :on_ignored_nl]
88
- body_tokens.pop while whitespace.include?(body_tokens[-1][1])
89
- # remove leading whitespace
90
- body_tokens.shift while whitespace.include?(body_tokens[0][1])
91
-
92
- # put them back together
93
- body_tokens.map {|token| token[2] }.join
94
- end
95
-
96
- def self.from_source(prc_src)
97
- raise ArgumentError unless prc_src.kind_of?(String)
98
- prc = eval(prc_src)
99
- prc.instance_variable_set(:@source, prc_src)
100
- prc
101
- end
102
-
103
- end
@@ -1,25 +0,0 @@
1
- # We use Hash#inspect in ExpressTemplates::Markup::Wrapper to reproduce arguments
2
- # to helpers in the Rails view.
3
- #
4
- # Hash#inspect calls #inspect on values and keys. This allows us to
5
- # place the resulting string into the view code with a simple substitution
6
- # or concatenation.
7
- #
8
- # In special cases, however, we might want the argument or one of its keys
9
- # or values to be the result of evaluating of a ruby expression in the view
10
- # that does not itself return a String. The result of #inspect
11
- # is normally a quoted and escaped string which would evaluate to a string
12
- # in the view. What we want is a simple string of code. Here we provide
13
- # a method that overrides #inspect in the strings eigenclass to strip off
14
- # enclosing quotes or unwanted escapes. It shouldn't bother anybody and
15
- # it keeps us from doing messy things elsewhere for now.
16
- class String
17
- def to_view_code
18
- class << self
19
- def inspect
20
- super.gsub(/^"(.*)"$/,'\1')
21
- end
22
- end
23
- return self
24
- end
25
- end
@@ -1,22 +0,0 @@
1
- module ExpressTemplates
2
- module Compiler
3
- def compile(template_or_src=nil, &block)
4
-
5
- template, src = _normalize(template_or_src)
6
-
7
- %Q[assigns.merge!(template_virtual_path: @virtual_path) ; Arbre::Context.new(assigns, self) { #{src || block.source_body} }.to_s]
8
- end
9
-
10
- private
11
- def _normalize(template_or_src)
12
- template, src = nil, nil
13
- if template_or_src.respond_to?(:source)
14
- template = template_or_src
15
- src = template_or_src.source
16
- else
17
- src = template_or_src
18
- end
19
- return template, src
20
- end
21
- end
22
- end
@@ -1,28 +0,0 @@
1
- module ExpressTemplates
2
- module Components
3
- module Presenters
4
- class All < Container
5
-
6
- has_argument :id, "Name of the collection", as: :collection_name, type: :symbol
7
-
8
- contains -> (&block) {
9
- prepended
10
- collection.each do |item|
11
- assigns[member_name.to_sym] = item
12
- block.call(self) if block
13
- end
14
- appended
15
- }
16
-
17
- def member_name
18
- config[:collection_name].to_s.singularize.to_sym
19
- end
20
-
21
- def collection
22
- self.send(config[:collection_name])
23
- end
24
-
25
- end
26
- end
27
- end
28
- end
@@ -1,156 +0,0 @@
1
- capabilities = Dir.glob(File.join(File.dirname(__FILE__), 'capabilities', '*.rb'))
2
- capabilities.each {|capability| require capability}
3
-
4
- module ExpressTemplates
5
- # Components provide self-contained reusable view code meant to be shared
6
- # within a project or across many projects through a library of components
7
- #
8
- module Components
9
-
10
- # Components::Base is the base class for ExpressTemplates view components.
11
- #
12
- #
13
- class Base < Arbre::Component
14
-
15
- class_attribute :before_build_hooks
16
- self.before_build_hooks = []
17
-
18
- class_attribute :builder_method_name
19
-
20
- # mark a component as abstract ie. can't be used
21
- # in Express Designer
22
- #
23
- @is_abstract = false
24
-
25
- def self.abstract_component(value = true)
26
- @is_abstract = value
27
- end
28
-
29
- def self.abstract_component?
30
- @is_abstract
31
- end
32
-
33
- abstract_component
34
-
35
- # define the parent componennt ie. can't be used
36
- # in Express Designer unless parent is present
37
- #
38
- @parent_component = nil
39
-
40
- def self.require_parent(component)
41
- raise "must pass a sublcass of ExpressTemplates::Components::Base" if !component.kind_of? ExpressTemplates::Components::Base
42
- @parent_component = component
43
- end
44
-
45
- def self.required_parent
46
- @parent_component
47
- end
48
-
49
- def self.builder_method_and_class(method_name, klass)
50
- Arbre::Element::BuilderMethods.class_eval <<-EOF, __FILE__, __LINE__
51
- def #{method_name}(*args, &block)
52
- insert_tag ::#{klass.name}, *args, &block
53
- end
54
- EOF
55
- self.builder_method_name = method_name
56
- # puts "added #{method_name} -> #{klass.name}"
57
- end
58
-
59
- def initialize(*)
60
- super
61
- _default_attributes.each do |name, value|
62
- set_attribute(name, value)
63
- end
64
- add_class _default_classes
65
- end
66
-
67
- def self.contains(proc = nil, &block)
68
- define_method(:_build_body, &(proc || block))
69
- end
70
-
71
- # Override the tag_name method for other than <div>
72
- def self.tag(tag)
73
- define_method(:tag_name) { tag }
74
- end
75
-
76
- # Provide default attributes for the enclosing tag
77
- # of the component
78
- def self.has_attributes(attribs)
79
- self._default_classes = attribs.delete(:class)
80
- _default_attributes.merge!(attribs)
81
- end
82
-
83
- def self.before_build(proc_or_symbol = nil, exclusive: false, &block)
84
- hook = (proc_or_symbol || block)
85
- unless hook.kind_of?(Symbol) or hook.respond_to?(:call)
86
- raise "before_build requires symbol (method_name), proc or block"
87
- end
88
- if exclusive
89
- self.before_build_hooks = [hook]
90
- else
91
- self.before_build_hooks += [hook]
92
- end
93
- end
94
-
95
- def build(*args, &block)
96
- _extract_class!(args)
97
- _run_before_build_hooks
98
- super(*args) {
99
- _build_body(&block) if respond_to?(:_build_body)
100
- }
101
- end
102
-
103
- def resource
104
- helpers.resource
105
- end
106
-
107
- def self.inherited(subclass)
108
- subclass.builder_method_and_class subclass.to_s.demodulize.underscore, subclass
109
- end
110
-
111
- def self.builder_method(name)
112
- builder_method_and_class name, self
113
- end
114
-
115
- def self.descendants
116
- ObjectSpace.each_object(Class).select { |klass| klass < self }
117
- end
118
-
119
- protected
120
- def default_class_name
121
- self.class.name.demodulize.underscore.dasherize
122
- end
123
-
124
-
125
- private
126
- def _run_before_build_hooks
127
- before_build_hooks.each do |hook|
128
- if hook.kind_of?(Symbol)
129
- self.send(hook)
130
- else
131
- instance_exec &hook
132
- end
133
- end
134
- end
135
- def _extract_class!(args)
136
- add_class args.last.delete(:class) if args.last.try(:kind_of?, Hash)
137
- end
138
- def _default_attributes
139
- self.class._default_attributes
140
- end
141
- def self._default_attributes
142
- @default_attributes ||= {}
143
- end
144
- def _default_classes
145
- self.class._default_classes
146
- end
147
- def self._default_classes
148
- @default_classes ||= ''
149
- end
150
- def self._default_classes=(classes)
151
- @default_classes = classes
152
- end
153
-
154
- end
155
- end
156
- end