BootstrapMan 0.1.0 → 0.1.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +147 -1
  3. data/BootstrapMan.gemspec +4 -4
  4. data/README.md +27 -2
  5. data/lib/BootstrapMan/version.rb +1 -1
  6. data/lib/generators/bootstrap/install/USAGE +13 -0
  7. data/lib/generators/bootstrap/install/install_generator.rb +46 -0
  8. data/lib/generators/bootstrap/install/templates/_footer.html.erb +6 -0
  9. data/lib/generators/bootstrap/install/templates/_footer.html.haml +8 -0
  10. data/lib/generators/bootstrap/install/templates/_footer.html.slim +4 -0
  11. data/lib/generators/bootstrap/install/templates/_navbar.html.erb +36 -0
  12. data/lib/generators/bootstrap/install/templates/_navbar.html.haml +29 -0
  13. data/lib/generators/bootstrap/install/templates/_navbar.html.slim +39 -0
  14. data/lib/generators/bootstrap/install/templates/application.js +22 -0
  15. data/lib/generators/bootstrap/install/templates/application.scss +2 -0
  16. data/lib/generators/bootstrap/install/templates/bootstrap_forms.scss +21 -0
  17. data/lib/generators/bootstrap/install/templates/layout.html.erb +23 -0
  18. data/lib/generators/bootstrap/install/templates/layout.html.haml +19 -0
  19. data/lib/generators/bootstrap/install/templates/layout.html.slim +50 -0
  20. data/lib/generators/bootstrap/strapify/USAGE +11 -0
  21. data/lib/generators/bootstrap/strapify/strapify_generator.rb +146 -0
  22. data/lib/generators/bootstrap/strapify/templates/edit.html.erb +5 -0
  23. data/lib/generators/bootstrap/strapify/templates/edit.html.haml +4 -0
  24. data/lib/generators/bootstrap/strapify/templates/edit.html.slim +4 -0
  25. data/lib/generators/bootstrap/strapify/templates/index.html.erb +40 -0
  26. data/lib/generators/bootstrap/strapify/templates/index.html.haml +26 -0
  27. data/lib/generators/bootstrap/strapify/templates/index.html.slim +28 -0
  28. data/lib/generators/bootstrap/strapify/templates/new.html.erb +5 -0
  29. data/lib/generators/bootstrap/strapify/templates/new.html.haml +4 -0
  30. data/lib/generators/bootstrap/strapify/templates/new.html.slim +4 -0
  31. data/lib/generators/bootstrap/strapify/templates/show.html.erb +21 -0
  32. data/lib/generators/bootstrap/strapify/templates/show.html.haml +15 -0
  33. data/lib/generators/bootstrap/strapify/templates/show.html.slim +16 -0
  34. metadata +34 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24f0ed74317108b07fc8bd88b5598525072e05d0e6f093aa53f082592d886eae
4
- data.tar.gz: 661a6f769f9299da41ff5fb2a22110d79d36ab9966e826a1f1cc3b546049dcb8
3
+ metadata.gz: 55a2ae02c16c64c625cc087353c9662977a9172fe4709338d00b57798c7d77f3
4
+ data.tar.gz: 4ff6cbb3600938c7bb569d4bc9d21c748e4d45852377c18cc7d150a5876911d1
5
5
  SHA512:
6
- metadata.gz: e2d56ad036b4c5f6b244dd54de9cc7a46edc4b7ccd56a8d4ec22c2f60466f64f51d0ec49916eb0cdd2c0b6a81f8244b3d5dcfd440bbdec3d64811cce75870dda
7
- data.tar.gz: '0339ea808b227fae2c2abbb90ca9dde1881705fd33851e4c58c5e335e9f0546c281d4e6d7c9df37bce776519e8c26b346afdde8883337344557602cfdfb6339a'
6
+ metadata.gz: 31dc10ff723ebf945166c8f8025aa730ea9760df786d3001c9665925f96b2e0dc7f2bcddf12a0e8b94e5d2118bace5644d793b2f5757ff6e3096f570661c8fa3
7
+ data.tar.gz: 604aa75760e47e69ea8b6e728e0a4aac6fc1d4e602aa7c5a83125e690200da0feb2848a5146b51077483931de529c7391c3d2ebc39ce77fc5ccfe36a242ec679
data/.gitignore CHANGED
@@ -1,11 +1,157 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,rails,macos
3
+ # Edit at https://www.gitignore.io/?templates=ruby,rails,macos
4
+
5
+ ### macOS ###
6
+ # General
7
+ .DS_Store
8
+ .AppleDouble
9
+ .LSOverride
10
+
11
+ # Icon must end with two \r
12
+ Icon
13
+
14
+ # Thumbnails
15
+ ._*
16
+
17
+ # Files that might appear in the root of a volume
18
+ .DocumentRevisions-V100
19
+ .fseventsd
20
+ .Spotlight-V100
21
+ .TemporaryItems
22
+ .Trashes
23
+ .VolumeIcon.icns
24
+ .com.apple.timemachine.donotpresent
25
+
26
+ # Directories potentially created on remote AFP share
27
+ .AppleDB
28
+ .AppleDesktop
29
+ Network Trash Folder
30
+ Temporary Items
31
+ .apdisk
32
+
33
+ ### Rails ###
34
+ *.rbc
35
+ capybara-*.html
36
+ .rspec
37
+ /log
38
+ /tmp
39
+ /db/*.sqlite3
40
+ /db/*.sqlite3-journal
41
+ /public/system
42
+ /coverage/
43
+ /spec/tmp
44
+ *.orig
45
+ rerun.txt
46
+ pickle-email-*.html
47
+
48
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
49
+ config/initializers/secret_token.rb
50
+ config/master.key
51
+
52
+ # Only include if you have production secrets in this file, which is no longer a Rails default
53
+ # config/secrets.yml
54
+
55
+ # dotenv
56
+ # TODO Comment out this rule if environment variables can be committed
57
+ .env
58
+
59
+ ## Environment normalization:
60
+ /.bundle
61
+ /vendor/bundle
62
+
63
+ # these should all be checked in to normalize the environment:
64
+ # Gemfile.lock, .ruby-version, .ruby-gemset
65
+
66
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
67
+ .rvmrc
68
+
69
+ # if using bower-rails ignore default bower_components path bower.json files
70
+ /vendor/assets/bower_components
71
+ *.bowerrc
72
+ bower.json
73
+
74
+ # Ignore pow environment settings
75
+ .powenv
76
+
77
+ # Ignore Byebug command history file.
78
+ .byebug_history
79
+
80
+ # Ignore node_modules
81
+ node_modules/
82
+
83
+ # Ignore precompiled javascript packs
84
+ /public/packs
85
+ /public/packs-test
86
+ /public/assets
87
+
88
+ # Ignore yarn files
89
+ /yarn-error.log
90
+ yarn-debug.log*
91
+ .yarn-integrity
92
+
93
+ # Ignore uploaded files in development
94
+ /storage/*
95
+ !/storage/.keep
96
+
97
+ ### Ruby ###
98
+ *.gem
99
+ /.config
100
+ /InstalledFiles
101
+ /pkg/
102
+ /spec/reports/
103
+ /spec/examples.txt
104
+ /test/tmp/
105
+ /test/version_tmp/
106
+ /tmp/
107
+
108
+ # Used by dotenv library to load environment variables.
109
+ # .env
110
+
111
+ # Ignore Byebug command history file.
112
+
113
+ ## Specific to RubyMotion:
114
+ .dat*
115
+ .repl_history
116
+ build/
117
+ *.bridgesupport
118
+ build-iPhoneOS/
119
+ build-iPhoneSimulator/
120
+
121
+ ## Specific to RubyMotion (use of CocoaPods):
122
+ #
123
+ # We recommend against adding the Pods directory to your .gitignore. However
124
+ # you should judge for yourself, the pros and cons are mentioned at:
125
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
126
+ # vendor/Pods/
127
+
128
+ ## Documentation cache and generated files:
129
+ /.yardoc/
130
+ /_yardoc/
131
+ /doc/
132
+ /rdoc/
133
+
1
134
  /.bundle/
135
+ /lib/bundler/man/
136
+
137
+ # for a library or gem, you might want to ignore these files since the code is
138
+ # intended to run in multiple environments; otherwise, check them in:
139
+ # Gemfile.lock
140
+ # .ruby-version
141
+ # .ruby-gemset
142
+
143
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
144
+
145
+ # End of https://www.gitignore.io/api/ruby,rails,macos
146
+
2
147
  /.yardoc
3
- /_yardoc/
148
+
4
149
  /coverage/
5
150
  /doc/
6
151
  /pkg/
7
152
  /spec/reports/
8
153
  /tmp/
9
154
 
155
+ BootstrapMan-0.1.0.gem
10
156
  # rspec failure tracking
11
157
  .rspec_status
data/BootstrapMan.gemspec CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
 
28
- spec.add_runtime_dependency "jquery-rails", "~> 4.3"
29
- spec.add_runtime_dependency "bootstrap", "~> 4.3.1"
30
- spec.add_runtime_dependency "font-awesome-rails", "~> 4.7"
31
- spec.add_runtime_dependency "bootstrap_form", "~> 4.1"
28
+ spec.add_dependency "jquery-rails", "~> 4.3"
29
+ spec.add_dependency "bootstrap", "~> 4.3.1"
30
+ spec.add_dependency "font-awesome-rails", "~> 4.7"
31
+ spec.add_dependency "bootstrap_form", "~> 4.1"
32
32
  end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/BootstrapMan`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ You don't need to customize the stylesheets manually, the only gem you need is the `BootstrapMan`
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,32 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### Installing the CSS stylesheets
26
+
27
+ After running `bundle install`, run the generator:
28
+
29
+ rails generate bootstrap:install
30
+
31
+ This command will create required asset files and update your application layout.
32
+
33
+ ## Generating layouts and views
34
+
35
+ You can run following generators to get started with Bootstrap quickly.
36
+
37
+ Strapify (generates Bootstrap compatible scaffold views.) - (Haml and Slim supported)
38
+
39
+ Usage:
40
+
41
+ rails g bootstrap:strapify [RESOURCE_NAME]
42
+
43
+
44
+ Example:
45
+
46
+ rails g scaffold Post title:string description:text
47
+ rake db:migrate
48
+ rails g bootstrap:themed Posts
49
+
50
+ Notice the plural usage of the resource to generate bootstrap:strapify.
26
51
 
27
52
  ## Development
28
53
 
@@ -1,3 +1,3 @@
1
1
  module BootstrapMan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,13 @@
1
+ Description:
2
+ This will deploy required Bootstrap Assets and Update Application Layout File
3
+
4
+ Example:
5
+ rails generate bootstrap:install
6
+
7
+ This will create:
8
+ app/assets/stylesheets/application.scss
9
+ app/assets/stylesheets/bootstrap_forms.scss
10
+ app/assets/javascripts/application.js
11
+ app/views/layouts/application.html.erb
12
+ app/views/layouts/shared/_navbar.html.erb
13
+ app/views/layouts/shared/_footer.html.erb
@@ -0,0 +1,46 @@
1
+ require 'rails/generators'
2
+ module Bootstrap
3
+ module Generators
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+ desc "This adds Bootstrap to Assets and Application Layout"
7
+
8
+ attr_reader :app_name
9
+
10
+ def add_assets
11
+ js_manifest = 'app/assets/javascripts/application.js'
12
+
13
+ if File.exist?(js_manifest)
14
+ insert_into_file js_manifest, "//= require jquery3\n//= require popper\n//= require bootstrap-sprockets\n", :after => "turbolinks\n"
15
+ else
16
+ copy_file "application.js", js_manifest
17
+ end
18
+
19
+ css_manifest = 'app/assets/stylesheets/application.css'
20
+ scss_manifest = 'app/assets/stylesheets/application.scss'
21
+
22
+ if File.exist?(css_manifest)
23
+ File.delete(css_manifest)
24
+ if File.exist?(scss_manifest)
25
+ File.delete(scss_manifest)
26
+ copy_file "application.scss", "app/assets/stylesheets/application.scss"
27
+ copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss"
28
+ else
29
+ copy_file "application.scss", "app/assets/stylesheets/application.scss"
30
+ copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss"
31
+ end
32
+ else
33
+ copy_file "application.scss", "app/assets/stylesheets/application.scss"
34
+ copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss"
35
+ end
36
+
37
+ app = ::Rails.application
38
+ @app_name = app.class.to_s.split("::").first
39
+ ext = app.config.generators.options[:rails][:template_engine] || :erb
40
+ template "layout.html.#{ext}", "app/views/layouts/application.html.#{ext}"
41
+ template "_navbar.html.#{ext}", "app/views/shared/_navbar.html.#{ext}"
42
+ template "_footer.html.#{ext}", "app/views/shared/_footer.html.#{ext}"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,6 @@
1
+ <footer class="footer mt-auto py-3 text-muted bg-dark">
2
+ <div class="container">
3
+ <p class="float-right"><a href="#">Back to top</a></p>
4
+ <p>&copy; Company <%%= Date.today.year %> &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
5
+ </div>
6
+ </footer>
@@ -0,0 +1,8 @@
1
+ %footer.container
2
+ %p.float-right
3
+ %a{:href => "#"} Back to top
4
+ %p
5
+ © 2017-2019 Company, Inc. ·
6
+ %a{:href => "#"} Privacy
7
+ ·
8
+ %a{:href => "#"} Terms
@@ -0,0 +1,4 @@
1
+ <footer class="container">
2
+ <p class="float-right"><a href="#">Back to top</a></p>
3
+ <p>&copy; 2017-2019 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
4
+ </footer>
@@ -0,0 +1,36 @@
1
+ <header>
2
+ <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
3
+ <%%= link_to "<%= app_name %>", "/", class: "nav-brand" %>
4
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
5
+ <span class="navbar-toggler-icon"></span>
6
+ </button>
7
+ <div class="collapse navbar-collapse" id="navbarsExampleDefault">
8
+ <ul class="navbar-nav mr-auto">
9
+ <li class="nav-item">
10
+ <%%= link_to "Link1", "/path1", class: "nav-link" %>
11
+ </li>
12
+ <li class="nav-item">
13
+ <%%= link_to "Link2", "/path2", class: "nav-link" %>
14
+ </li>
15
+ <li class="nav-item">
16
+ <%%= link_to "Link3", "/path3", class: "nav-link" %>
17
+ </li>
18
+ <li class="nav-item">
19
+ <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
20
+ </li>
21
+ <li class="nav-item dropdown">
22
+ <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
23
+ <div class="dropdown-menu" aria-labelledby="dropdown01">
24
+ <a class="dropdown-item" href="#">Action</a>
25
+ <a class="dropdown-item" href="#">Another action</a>
26
+ <a class="dropdown-item" href="#">Something else here</a>
27
+ </div>
28
+ </li>
29
+ </ul>
30
+ <form class="form-inline my-2 my-lg-0">
31
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
32
+ <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
33
+ </form>
34
+ </div>
35
+ </nav>
36
+ </header>
@@ -0,0 +1,29 @@
1
+ %nav.navbar.navbar-expand-md.navbar-dark.bg-dark.fixed-top
2
+ \%= link_to app_name, "/", class: "navbar-brand" %&gt;
3
+ %button.navbar-toggler{"aria-controls" => "navbarsExampleDefault", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-target" => "#navbarsExampleDefault", "data-toggle" => "collapse", :type => "button"}
4
+ %span.navbar-toggler-icon
5
+ #navbarsExampleDefault.collapse.navbar-collapse
6
+ %ul.navbar-nav.mr-auto
7
+ %li.nav-item
8
+ = 'active' if current_page?(/)
9
+ "&gt;
10
+ \#{link_to / do}
11
+ Home
12
+ \#{(content_tag :span, (current), :class = sr-only) if current_page?(/)}
13
+ %li.nav-item
14
+ \%= link_to "Link1", "/path1", class: "nav-link" %&gt;
15
+ %li.nav-item
16
+ \%= link_to "Link2", "/path2", class: "nav-link" %&gt;
17
+ %li.nav-item
18
+ \%= link_to "Link3", "/path3", class: "nav-link" %&gt;
19
+ %li.nav-item
20
+ %a.nav-link.disabled{"aria-disabled" => "true", :href => "#", :tabindex => "-1"} Disabled
21
+ %li.nav-item.dropdown
22
+ %a#dropdown01.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#"} Dropdown
23
+ .dropdown-menu{"aria-labelledby" => "dropdown01"}
24
+ %a.dropdown-item{:href => "#"} Action
25
+ %a.dropdown-item{:href => "#"} Another action
26
+ %a.dropdown-item{:href => "#"} Something else here
27
+ %form.form-inline.my-2.my-lg-0
28
+ %input.form-control.mr-sm-2{"aria-label" => "Search", :placeholder => "Search", :type => "text"}
29
+ %button.btn.btn-secondary.my-2.my-sm-0{:type => "submit"} Search
@@ -0,0 +1,39 @@
1
+ <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
2
+ <%%= link_to app_name, "/", class: "navbar-brand" %>
3
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
4
+ <span class="navbar-toggler-icon"></span>
5
+ </button>
6
+ <div class="collapse navbar-collapse" id="navbarsExampleDefault">
7
+ <ul class="navbar-nav mr-auto">
8
+ <li class="nav-item <%= 'active' if current_page?("/") %>">
9
+ <%= link_to "/" do %>Home
10
+ <%= (content_tag :span, "(current)", :class => "sr-only") if current_page?("/") %>
11
+ <% end %>
12
+ </li>
13
+ <li class="nav-item">
14
+ <%%= link_to "Link1", "/path1", class: "nav-link" %>
15
+ </li>
16
+ <li class="nav-item">
17
+ <%%= link_to "Link2", "/path2", class: "nav-link" %>
18
+ </li>
19
+ <li class="nav-item">
20
+ <%%= link_to "Link3", "/path3", class: "nav-link" %>
21
+ </li>
22
+ <li class="nav-item">
23
+ <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
24
+ </li>
25
+ <li class="nav-item dropdown">
26
+ <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
27
+ <div class="dropdown-menu" aria-labelledby="dropdown01">
28
+ <a class="dropdown-item" href="#">Action</a>
29
+ <a class="dropdown-item" href="#">Another action</a>
30
+ <a class="dropdown-item" href="#">Something else here</a>
31
+ </div>
32
+ </li>
33
+ </ul>
34
+ <form class="form-inline my-2 my-lg-0">
35
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
36
+ <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
37
+ </form>
38
+ </div>
39
+ </nav>
@@ -0,0 +1,22 @@
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, or any plugin's
5
+ // vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ // Code is generated via Bootstrap Man Gem, Checkout README (https://github.com/AndyMental/bootstrap-man)
14
+ // for details.
15
+ //
16
+ //= require rails-ujs
17
+ //= require activestorage
18
+ //= require turbolinks
19
+ //= require jquery3
20
+ //= require popper
21
+ //= require bootstrap-sprockets
22
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ @import "bootstrap";
2
+ @import "bootstrap_forms";
@@ -0,0 +1,21 @@
1
+ .rails-bootstrap-forms-date-select {
2
+ select {
3
+ display: inline-block;
4
+ width: auto;
5
+ }
6
+ }
7
+ .rails-bootstrap-forms-time-select {
8
+ select {
9
+ display: inline-block;
10
+ width: auto;
11
+ }
12
+ }
13
+ .rails-bootstrap-forms-datetime-select {
14
+ select {
15
+ display: inline-block;
16
+ width: auto;
17
+ }
18
+ }
19
+ .rails-bootstrap-forms-error-summary {
20
+ margin-top: 10px;
21
+ }
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="h-100">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
+ <meta name="description" content="">
7
+ <meta name="author" content="">
8
+ <title><%%= content_for?(:title) ? yield(:title) : "<%= app_name %>" %></title>
9
+ <link rel="canonical" href="<%%= "#{request.protocol}#{request.host}#{request.path}" %>">
10
+ <%%= csrf_meta_tags %>
11
+ <%%= stylesheet_link_tag "application", :media => "all" %>
12
+ <%%= javascript_include_tag "application" %>
13
+ </head>
14
+ <body class="d-flex flex-column h-100">
15
+ <%%= render "shared/navbar" %>
16
+ <main role="main" class="flex-shrink-0">
17
+ <div class="container">
18
+ <%%= yield %>
19
+ </div>
20
+ </main>
21
+ <%%= render "shared/footer" %>
22
+ </body>
23
+ </html>
@@ -0,0 +1,19 @@
1
+ !!!
2
+ %html{lang: "en"}
3
+ %head
4
+ %meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ %meta{charset: "utf-8"}/
6
+ %meta{content: "width=device-width, initial-scale=1, shrink-to-fit=no", name: "viewport"}/
7
+ %meta{content: "", name: "description"}/
8
+ %meta{content: "", name: "author"}/
9
+ %title
10
+ = content_for?(:title) ? yield(:title) : "<%= app_name %>"
11
+ %link{href: "#{request.protocol}#{request.host}#{request.path}", rel: "canonical"}/
12
+ = csrf_meta_tags
13
+ = stylesheet_link_tag "application", :media => "all"
14
+ = javascript_include_tag "application"
15
+ %body
16
+ = render "shared/navbar"
17
+ %main.container{role: "main"}
18
+ = yield
19
+ = render "shared/footer"
@@ -0,0 +1,50 @@
1
+ doctype html
2
+ html lang="en"
3
+ head
4
+ meta charset="utf-8"
5
+ meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
6
+ meta name="viewport" content="width=device-width, initial-scale=1.0"
7
+ title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
8
+ = csrf_meta_tags
9
+ = stylesheet_link_tag "application", :media => "all"
10
+ = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144'
11
+ = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114'
12
+ = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72'
13
+ = favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png'
14
+ = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'
15
+ = javascript_include_tag "application"
16
+ /! Le HTML5 shim, for IE6-8 support of HTML elements
17
+ /[if lt IE 9]
18
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"
19
+
20
+
21
+ body
22
+ .navbar.navbar-default.navbar-static-top
23
+ .container
24
+ button.navbar-toggle type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse"
25
+ span.icon-bar
26
+ span.icon-bar
27
+ span.icon-bar
28
+ a.navbar-brand href="#"<%= app_name %>
29
+ .navbar-collapse.collapse.navbar-responsive-collapse
30
+ ul.nav.navbar-nav
31
+ li= link_to "Link 1", "/path1"
32
+ li= link_to "Link 2", "/path2"
33
+ li= link_to "Link 3", "/path3"
34
+
35
+ .container
36
+ .row
37
+ .col-lg-9
38
+ = bootstrap_flash
39
+ = yield
40
+ .col-lg-3
41
+ .well.sidebar-nav
42
+ h3 Sidebar
43
+ ul.nav.nav-list
44
+ li.nav-header Sidebar
45
+ li= link_to "Link 1", "/path1"
46
+ li= link_to "Link 2", "/path2"
47
+ li= link_to "Link 3", "/path3"
48
+
49
+ footer
50
+ p &copy; Company <%= Date.today.year %>
@@ -0,0 +1,11 @@
1
+ Description:
2
+ This generator will updated all the files for given controller without form.
3
+
4
+ Example:
5
+ rails generate bootstrap:strapify things
6
+
7
+ This will update:
8
+ app/views/things/index.html.erb
9
+ app/views/things/edit.html.erb
10
+ app/views/things/new.html.erb
11
+ app/views/things/show.html.erb
@@ -0,0 +1,146 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ module Bootstrap
5
+ module Generators
6
+ class StrapifyGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :controller_path, :type => :string
9
+ argument :model_name, :type => :string, :required => false
10
+ argument :layout, :type => :string, :default => "application",
11
+ :banner => "Specify application layout"
12
+
13
+ class_option :excluded_columns, :type => :array, :required => false
14
+
15
+ def initialize(args, *options)
16
+ super(args, *options)
17
+ initialize_views_variables
18
+ end
19
+
20
+ def copy_views
21
+ generate_views
22
+ end
23
+
24
+ protected
25
+
26
+ def initialize_views_variables
27
+ @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
28
+ @controller_routing_path = @controller_file_path.gsub(/\//, '_')
29
+ @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
30
+ @model_name = @model_name.camelize
31
+ end
32
+
33
+ def controller_routing_path
34
+ ActiveModel::Naming.route_key(@model_name.constantize)
35
+ end
36
+
37
+ def singular_controller_routing_path
38
+ ActiveModel::Naming.singular_route_key(@model_name.constantize)
39
+ end
40
+
41
+ def model_name
42
+ @model_name
43
+ end
44
+
45
+ def plural_model_name
46
+ @model_name.pluralize
47
+ end
48
+
49
+ def resource_name_with_prefix
50
+ "@#{resource_name}"
51
+ end
52
+
53
+ def resource_name
54
+ @model_name.demodulize.underscore
55
+ end
56
+
57
+ def plural_resource_name
58
+ resource_name.pluralize
59
+ end
60
+
61
+ def columns
62
+ retrieve_columns.reject {|c| excluded?(c.name) }.map do |c|
63
+ new_attribute(c.name, c.type.to_s)
64
+ end
65
+ end
66
+
67
+ def excluded_columns_names
68
+ %w[_id _type id created_at updated_at]
69
+ end
70
+
71
+ def excluded_columns_pattern
72
+ [
73
+ /.*_checksum/,
74
+ /.*_count/,
75
+ ]
76
+ end
77
+
78
+ def excluded_columns
79
+ options['excluded_columns']||[]
80
+ end
81
+
82
+ def excluded?(name)
83
+ excluded_columns_names.include?(name) ||
84
+ excluded_columns_pattern.any? {|p| name =~ p } ||
85
+ excluded_columns.include?(name)
86
+ end
87
+
88
+ def retrieve_columns
89
+ if defined?(ActiveRecord) == "constant" && ActiveRecord.class == Module
90
+ rescue_block ActiveRecord::StatementInvalid do
91
+ @model_name.constantize.columns
92
+ end
93
+ else
94
+ rescue_block do
95
+ @model_name.constantize.fields.map {|c| c[1] }
96
+ end
97
+ end
98
+ end
99
+
100
+ def new_attribute(name, type)
101
+ ::Rails::Generators::GeneratedAttribute.new(name, type)
102
+ end
103
+
104
+ def rescue_block(exception=Exception)
105
+ yield if block_given?
106
+ rescue exception => e
107
+ say e.message, :red
108
+ exit
109
+ end
110
+
111
+ def extract_modules(name)
112
+ modules = name.include?('/') ? name.split('/') : name.split('::')
113
+ name = modules.pop
114
+ path = modules.map { |m| m.underscore }
115
+ file_path = (path + [name.underscore]).join('/')
116
+ nesting = modules.map { |m| m.camelize }.join('::')
117
+ [name, path, file_path, nesting, modules.size]
118
+ end
119
+
120
+ def generate_views
121
+ options.engine == generate_erb(selected_views)
122
+ end
123
+
124
+ def selected_views
125
+ {
126
+ "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
127
+ "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
128
+ "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
129
+ "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")
130
+ }
131
+ end
132
+
133
+ def generate_erb(views)
134
+ views.each do |template_name, output_path|
135
+ template template_name, output_path
136
+ end
137
+ end
138
+
139
+ def ext
140
+ ::Rails.application.config.generators.options[:rails][:template_engine] || :erb
141
+ end
142
+ end
143
+ end
144
+ end
145
+
146
+
@@ -0,0 +1,5 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header mt-5 pt-5">
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+ <%%= render :partial => 'form' %>
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,40 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header mt-5 pt-5">
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
4
+ </div>
5
+ <table class="table table-striped">
6
+ <thead>
7
+ <tr>
8
+ <th><%%= model_class.human_attribute_name(:id) %></th>
9
+ <%- columns.each do |column| -%>
10
+ <th><%%= model_class.human_attribute_name(:<%= column.name %>) %></th>
11
+ <%- end -%>
12
+ <th><%%= model_class.human_attribute_name(:created_at) %></th>
13
+ <th><%%=t '.actions', :default => t("helpers.actions") %></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %>
18
+ <tr>
19
+ <td><%%= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %></td>
20
+ <%- columns.each do |column| -%>
21
+ <td><%%= <%= resource_name %>.<%= column.name %> %></td>
22
+ <%- end -%>
23
+ <td><%%=l <%= resource_name %>.created_at %></td>
24
+ <td>
25
+ <%%= link_to t('.show', :default => t("helpers.links.show")),
26
+ <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs' %>
27
+ <%%= link_to t('.edit', :default => t("helpers.links.edit")),
28
+ edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs' %>
29
+ <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
30
+ <%= singular_controller_routing_path %>_path(<%= resource_name %>),
31
+ :method => :delete,
32
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
33
+ :class => 'btn btn-xs btn-danger' %>
34
+ </td>
35
+ </tr>
36
+ <%% end %>
37
+ </tbody>
38
+ </table>
39
+ <%%= link_to t('.new', :default => t("helpers.links.new")),
40
+ new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary' %>
@@ -0,0 +1,26 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
+ %table.table.table-striped
5
+ %thead
6
+ %tr
7
+ %th= model_class.human_attribute_name(:id)
8
+ <%- columns.each do |column| -%>
9
+ %th= model_class.human_attribute_name(:<%= column.name %>)
10
+ <%- end -%>
11
+ %th= model_class.human_attribute_name(:created_at)
12
+ %th=t '.actions', :default => t("helpers.actions")
13
+ %tbody
14
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
+ %tr
16
+ %td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
+ <%- columns.each do |column| -%>
18
+ %td= <%= resource_name %>.<%= column.name %>
19
+ <%- end -%>
20
+ %td=l <%= resource_name %>.created_at
21
+ %td
22
+ = link_to t('.show', :default => t("helpers.links.show")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
23
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
24
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger'
25
+
26
+ = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
@@ -0,0 +1,28 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
+ table.table.table-striped
5
+ thead
6
+ tr
7
+ th= model_class.human_attribute_name(:id)
8
+ <%- columns.each do |column| -%>
9
+ th= model_class.human_attribute_name(:<%= column.name %>)
10
+ <%- end -%>
11
+ th= model_class.human_attribute_name(:created_at)
12
+ th=t '.actions', :default => t("helpers.actions")
13
+ tbody
14
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
+ tr
16
+ td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
+ <%- columns.each do |column| -%>
18
+ td= <%= resource_name %>.<%= column.name %>
19
+ <%- end -%>
20
+ td=l <%= resource_name %>.created_at
21
+ td
22
+ = link_to t('.show', :default => t("helpers.links.show")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
23
+ '
24
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-default btn-xs'
25
+ '
26
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs btn-danger'
27
+
28
+ = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
@@ -0,0 +1,5 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header mt-5 pt-5">
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+ <%%= render :partial => 'form' %>
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,4 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
+ = render :partial => "form"
@@ -0,0 +1,21 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header mt-5 pt-5">
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.titleize %></h1>
4
+ </div>
5
+
6
+ <dl class="dl-horizontal">
7
+ <%- columns.each do |column| -%>
8
+ <dt><strong><%%= model_class.human_attribute_name(:<%= column.name %>) %>:</strong></dt>
9
+ <dd><%%= @<%= resource_name %>.<%= column.name %> %></dd>
10
+ <%- end -%>
11
+ </dl>
12
+
13
+ <%%= link_to t('.back', :default => t("helpers.links.back")),
14
+ <%= controller_routing_path %>_path, :class => 'btn btn-default' %>
15
+ <%%= link_to t('.edit', :default => t("helpers.links.edit")),
16
+ edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default' %>
17
+ <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
18
+ <%= singular_controller_routing_path %>_path(@<%= resource_name %>),
19
+ :method => 'delete',
20
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
21
+ :class => 'btn btn-danger' %>
@@ -0,0 +1,15 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => model_class.model_name.human.titleize
4
+
5
+ <%- columns.each do |column| -%>
6
+ %p
7
+ %strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ %br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+
13
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
14
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
15
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -0,0 +1,16 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ h1=t '.title', :default => model_class.model_name.human.titleize
4
+
5
+ <%- columns.each do |column| -%>
6
+ p
7
+ strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
13
+ '
14
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
15
+ '
16
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BootstrapMan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMental
@@ -129,6 +129,39 @@ files:
129
129
  - bin/setup
130
130
  - lib/BootstrapMan.rb
131
131
  - lib/BootstrapMan/version.rb
132
+ - lib/generators/.DS_Store
133
+ - lib/generators/bootstrap/install/.DS_Store
134
+ - lib/generators/bootstrap/install/USAGE
135
+ - lib/generators/bootstrap/install/install_generator.rb
136
+ - lib/generators/bootstrap/install/templates/.DS_Store
137
+ - lib/generators/bootstrap/install/templates/_footer.html.erb
138
+ - lib/generators/bootstrap/install/templates/_footer.html.haml
139
+ - lib/generators/bootstrap/install/templates/_footer.html.slim
140
+ - lib/generators/bootstrap/install/templates/_navbar.html.erb
141
+ - lib/generators/bootstrap/install/templates/_navbar.html.haml
142
+ - lib/generators/bootstrap/install/templates/_navbar.html.slim
143
+ - lib/generators/bootstrap/install/templates/application.js
144
+ - lib/generators/bootstrap/install/templates/application.scss
145
+ - lib/generators/bootstrap/install/templates/bootstrap_forms.scss
146
+ - lib/generators/bootstrap/install/templates/layout.html.erb
147
+ - lib/generators/bootstrap/install/templates/layout.html.haml
148
+ - lib/generators/bootstrap/install/templates/layout.html.slim
149
+ - lib/generators/bootstrap/strapify/.DS_Store
150
+ - lib/generators/bootstrap/strapify/USAGE
151
+ - lib/generators/bootstrap/strapify/strapify_generator.rb
152
+ - lib/generators/bootstrap/strapify/templates/.DS_Store
153
+ - lib/generators/bootstrap/strapify/templates/edit.html.erb
154
+ - lib/generators/bootstrap/strapify/templates/edit.html.haml
155
+ - lib/generators/bootstrap/strapify/templates/edit.html.slim
156
+ - lib/generators/bootstrap/strapify/templates/index.html.erb
157
+ - lib/generators/bootstrap/strapify/templates/index.html.haml
158
+ - lib/generators/bootstrap/strapify/templates/index.html.slim
159
+ - lib/generators/bootstrap/strapify/templates/new.html.erb
160
+ - lib/generators/bootstrap/strapify/templates/new.html.haml
161
+ - lib/generators/bootstrap/strapify/templates/new.html.slim
162
+ - lib/generators/bootstrap/strapify/templates/show.html.erb
163
+ - lib/generators/bootstrap/strapify/templates/show.html.haml
164
+ - lib/generators/bootstrap/strapify/templates/show.html.slim
132
165
  homepage: https://github.com/AndyMental/bootstrap-man
133
166
  licenses:
134
167
  - MIT