templates-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fb94bce07ae247f36c8b9a45332b562158fb7cc51e909c9d3d7737d3e7e30201
4
+ data.tar.gz: 98b3fe59cc0022810e87a0aa5b3485d8522ea99c03f9f26133982b5b471e4bab
5
+ SHA512:
6
+ metadata.gz: 26e76e6bd2031e4856534a23977d32c8dd674266ee371c9623e498e171b467b90c40c814f19ca337564702124c395efac8b40738126f1346426b40bf315d47a9
7
+ data.tar.gz: f075cdff765cd1b22e80866bded4e9921662d7f773f31428d75e72e192ddf71f20316286f6f237a9279121c192493d8fd8a93ba795e01c07720e0421f915be7f
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Ancez
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Templates
2
+ [![Gem Version](http://img.shields.io/gem/v/templates-rails.svg)](https://github.com/Ancez/templates-rails/blob/master/CHANGELOG.md)
3
+ [![Rspec](https://github.com/Ancez/templates-rails/actions/workflows/rspec.yml/badge.svg)](https://github.com/Ancez/templates-rails/actions/workflows/rspec.yml)
4
+ [![Ruby Gem](https://github.com/Ancez/templates-rails/actions/workflows/gem-push.yml/badge.svg)](https://rubygems.org/gems/templates-rails)
5
+
6
+ Simple to use templating system for your Rails application. Design your views before implementation.
7
+
8
+ Dummy can be viewed [here](https://templates-rails.herokuapp.com/).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'templates-rails'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install templates-rails
25
+
26
+ Run
27
+
28
+ $ rake templates:install
29
+ - This will add the templates engine to your routes by adding:
30
+ - `mount Templates::Engine => '/'`
31
+ - And will automatically generate `views/templates/example` directory and an example `.html.erb` file `/views/templates/example.html.erb`
32
+ - It will also generate empty `partials` directories to showcase that you can still partialise your design views with a structure
33
+ - `partials` directories are excluded from being shown within the indexes
34
+
35
+ ## Usage
36
+
37
+ The rake task mentioned above generates examples for you to edit, delete and/or copy from.
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Ancez/templates-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Ancez/templates-rails/blob/master/CODE_OF_CONDUCT.md).
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the templates-rails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/templating/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+
3
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
4
+ load 'rails/tasks/engine.rake'
5
+
6
+ load 'rails/tasks/statistics.rake'
7
+
8
+ require 'bundler/gem_tasks'
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/templates .css
@@ -0,0 +1,73 @@
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 any plugin's vendor/assets/stylesheets directory 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 other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
16
+
17
+ .templates {
18
+ display: flex;
19
+ flex-direction: column;
20
+ margin: 0;
21
+ }
22
+
23
+ .templates a {
24
+ background-color: #ffffff;
25
+ border-radius: 5px;
26
+ border: 1px solid #3D7EB8;
27
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
28
+ color: #3D7EB8;
29
+ display: block;
30
+ margin: 12px;
31
+ padding: 8px 12px;
32
+ text-decoration: none;
33
+ transition: color, background-color 300ms ease;
34
+ }
35
+
36
+ .templates a:hover {
37
+ background-color: #3D7EB8;
38
+ color: #ffffff;
39
+ }
40
+
41
+ .templates__header {
42
+ background-color: #5893C7;
43
+ border-bottom: 1px solid #3D7EB8;
44
+ color: #ffffff;
45
+ display: flex;
46
+ justify-content: center;
47
+ }
48
+
49
+ .templates__header div {
50
+ align-items: center;
51
+ display: flex;
52
+ justify-content: space-between;
53
+ max-width: 1440px;
54
+ min-height: 60px;
55
+ width: 100%;
56
+ }
57
+
58
+ .templates__header div h1 {
59
+ margin: 6px 0;
60
+ padding: 0 24px;
61
+ }
62
+
63
+ .templates__content {
64
+ display: flex;
65
+ justify-content: center;
66
+ }
67
+
68
+ .templates__content div {
69
+ display: flex;
70
+ flex-wrap: wrap;
71
+ max-width: 1440px;
72
+ width: 100%;
73
+ }
@@ -0,0 +1,13 @@
1
+ class Templates::TemplatesController < ApplicationController
2
+ def index
3
+ render :index, layout: 'templates/index'
4
+ end
5
+
6
+ def show
7
+ if params[:id].present? && File.directory?("./app/views/templates/#{params[:id]}")
8
+ render :nested_index, layout: 'templates/index'
9
+ else
10
+ render "templates/#{params[:id]}", layout: 'templates/show'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= yield(:title) if content_for?(:title) %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+
7
+ <%= stylesheet_link_tag 'templates/application', media: 'all' %>
8
+ </head>
9
+
10
+ <body class="templates">
11
+ <div class="templates__header">
12
+ <div>
13
+ <h1><%= yield(:title) if content_for?(:title) %></h1>
14
+ <%= link_to 'Go Back', templates_path if params[:id].present? %>
15
+ </div>
16
+ </div>
17
+
18
+ <div class="templates__content">
19
+ <%= yield %>
20
+ </div>
21
+ </body>
22
+ </html>
@@ -0,0 +1 @@
1
+ <%= render template: yield(:layout_override).present? ? "/layouts/#{yield(:layout_override)}" : 'layouts/application' %>
@@ -0,0 +1,7 @@
1
+ <% provide(:title, 'Templates') %>
2
+
3
+ <div>
4
+ <% Dir.children('./app/views/templates').excluding('partials').sort.each do |child| %>
5
+ <%= link_to child.chomp('.html.erb').humanize.titleize, template_path(child.chomp('.html.erb')), class: 'button button--blue' %>
6
+ <% end %>
7
+ </div>
@@ -0,0 +1,7 @@
1
+ <% provide(:title, params[:id].gsub('/', ' / ').titleize) %>
2
+
3
+ <div>
4
+ <% Dir.children("./app/views/templates/#{params[:id]}").excluding('partials').sort.each do |child| %>
5
+ <%= link_to child.chomp('.html.erb').humanize.titleize, template_path("#{params[:id]}/#{child.chomp('.html.erb')}"), class: 'button button--blue' %>
6
+ <% end %>
7
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Templates::Engine.routes.draw do
2
+ root 'templates#index'
3
+ resources :templates, only: [:index, :show]
4
+ end
@@ -0,0 +1,10 @@
1
+ say 'Mounting Engine'
2
+ insert_into_file(
3
+ 'config/routes.rb',
4
+ %(mount Templates::Engine => '/' if Rails.env.development?),
5
+ before: /\s*end/
6
+ )
7
+ append_to_file 'config/routes.rb', %(mount Templates::Engine => '/' if Rails.env.development?\n), before: "\nend"
8
+
9
+ say 'Creating Templates Directory'
10
+ file_create 'app/views/templates/example.html.erb', "<%= provide(:title, 'Example') %>\nExample"
@@ -0,0 +1,13 @@
1
+ def run_templates_install_template(path) system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}" end
2
+
3
+ namespace :templates do
4
+ desc 'Install Templates'
5
+ task :install do
6
+ if Rails.root.join('config/routes.rb').exist?
7
+ run_templates_install_template 'templates'
8
+ else
9
+ puts 'config/routes.rb file found'
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,9 @@
1
+ module Templates
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Templates
4
+
5
+ initializer 'templates.assets.precompile' do |app|
6
+ app.config.assets.precompile += %w( application.css )
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Templates
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'templates/version'
2
+ require 'templates/engine'
3
+
4
+ module Templates
5
+ # Your code goes here...
6
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: templates-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lukasz Czapiewski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A templating system for creating and making design decisions for your
28
+ Rails application. Make your design decisions before you build your application
29
+ views.
30
+ email:
31
+ - luke@mmtm.io
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - app/assets/config/templates_manifest.js
40
+ - app/assets/stylesheets/templates/application.css
41
+ - app/controllers/templates/templates_controller.rb
42
+ - app/views/layouts/templates/index.html.erb
43
+ - app/views/layouts/templates/show.html.erb
44
+ - app/views/templates/templates/index.html.erb
45
+ - app/views/templates/templates/nested_index.html.erb
46
+ - config/routes.rb
47
+ - lib/install/templates.rb
48
+ - lib/tasks/templates_tasks.rake
49
+ - lib/templates-rails.rb
50
+ - lib/templates/engine.rb
51
+ - lib/templates/version.rb
52
+ homepage: https://github.com/Ancez/templates-rails
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/Ancez/templates-rails
57
+ source_code_uri: https://github.com/Ancez/templates-rails
58
+ changelog_uri: https://github.com/Ancez/templates-rails/CHANGELOG.md
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.3.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Simple to use templating system for your Rails application. Design your views
78
+ before implementation.
79
+ test_files: []