bravura_template_base 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9ffbbc8ddafcfc768e0f7931aa3836319dd8b8766c10cc67f12221e95e338ded
4
+ data.tar.gz: 6d81f3eb5d57241104d7978682b0a61d94c8bd640565b97d067adb9070508c0b
5
+ SHA512:
6
+ metadata.gz: cbc602c95cf0e9d90aec2192bf197db082e56d5d39276d26ee2d9e140da42b40515ef8e629fad7ce83450c66ebb86080a867d8febfdc73841fe82050c5f4d48d
7
+ data.tar.gz: 7a7a833d6b477d24222c1c162803e26b6b1b8d7d7dfeeff666cea844f04dcd4b2a2b4d4bb0e950a0bc9d16bf8cc13eb88ecdafc7cd5e62544dd626761e649fb5
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright captproton
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.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # BravuraTemplateBase
2
+ What the `bravura_template_base` gem does:
3
+
4
+ 1. Template Management:
5
+ - The gem provides a system for managing and loading different blog templates.
6
+ - It defines a set of available templates and a default template.
7
+
8
+ 2. Dynamic Template Loading:
9
+ - The `load_template` method dynamically loads a template based on the account's settings.
10
+ - It handles the loading of template-specific assets (JavaScript and CSS) into the Rails asset pipeline.
11
+
12
+ 3. Fallback Mechanism:
13
+ - If a specified template doesn't exist, it falls back to the default template.
14
+ - It logs a warning when falling back to the default template.
15
+
16
+ 4. Error Handling:
17
+ - It raises an error if the default template is not found.
18
+ - It validates that the account object has the necessary attributes.
19
+
20
+ 5. Flexible Configuration:
21
+ - The gem allows for different templates to be defined and used without modifying the main application code.
22
+
23
+ 6. Asset Management:
24
+ - It adds template-specific asset paths to the Rails asset pipeline.
25
+ - It adds template-specific CSS to the precompile list.
26
+
27
+ In essence, this gem serves as a foundation for a multi-template blog system. It allows different accounts to use different blog templates, all managed through a central system. The main benefits are:
28
+
29
+ 1. Modularity: Templates can be developed and managed separately from the main application.
30
+ 2. Flexibility: Accounts can easily switch between different templates.
31
+ 3. Consistency: It provides a standard way to handle different blog templates across the application.
32
+ 4. Error Handling: It gracefully handles cases where a template might be missing or incorrectly specified.
33
+
34
+ The gem is designed to work within a larger Rails application, where it can be used to dynamically load and manage different blog templates based on account settings. It's a key component in creating a flexible, multi-tenant blogging platform where different users or accounts can have different looking blogs all running on the same underlying system.
35
+
36
+ ## Usage
37
+ How to use my plugin.
38
+
39
+ ## Installation
40
+ Add this line to your application's Gemfile:
41
+
42
+ ```ruby
43
+ gem "bravura_template_base"
44
+ ```
45
+
46
+ And then execute:
47
+ ```bash
48
+ $ bundle
49
+ ```
50
+
51
+ Or install it yourself as:
52
+ ```bash
53
+ $ gem install bravura_template_base
54
+ ```
55
+
56
+ ## Contributing
57
+ Contribution directions go here.
58
+
59
+ ## License
60
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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/bravura_template_base .css
@@ -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 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
+ */
@@ -0,0 +1,4 @@
1
+ module BravuraTemplateBase
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BravuraTemplateBase
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BravuraTemplateBase
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module BravuraTemplateBase
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module BravuraTemplateBase
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Bravura template base</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "bravura_template_base/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ BravuraTemplateBase::Engine.routes.draw do
2
+ end
@@ -0,0 +1,11 @@
1
+ module BravuraTemplateBase
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace BravuraTemplateBase
4
+
5
+ initializer "bravura_template_base.assets" do |app|
6
+ BravuraTemplateBase::AVAILABLE_TEMPLATES.each do |template_name|
7
+ BravuraTemplateBase.load_template(app, template_name)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module BravuraTemplateBase
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ module BravuraTemplateBase
2
+ AVAILABLE_TEMPLATES = [ "bravura_template_normal", "bravura_template_product_updates" ]
3
+ DEFAULT_TEMPLATE = "bravura_template_normal"
4
+
5
+ def self.load_template(app, account)
6
+ raise ArgumentError, "account must respond to :settings and :id" unless account.respond_to?(:settings) && account.respond_to?(:id)
7
+
8
+ template_name = account.settings.design.blog_template_gem
9
+
10
+ begin
11
+ engine_class = "#{template_name.camelize}::Engine".constantize
12
+ app.config.assets.paths << engine_class.root.join("app/javascript")
13
+ app.config.assets.precompile << "#{template_name}/application.css"
14
+ rescue NameError => e
15
+ logger.warn "Template #{template_name} not found for account #{account.id}, falling back to default"
16
+ if template_name != DEFAULT_TEMPLATE
17
+ account.settings.design.blog_template_gem = DEFAULT_TEMPLATE
18
+ load_template(app, account)
19
+ else
20
+ raise "Default template #{DEFAULT_TEMPLATE} not found: #{e.message}"
21
+ end
22
+ end
23
+ end
24
+
25
+ def self.logger
26
+ Rails.logger || Logger.new(STDOUT)
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bravura_template_base do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bravura_template_base
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Carl Tanner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-08 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: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '6.1'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 6.1.3
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '6.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 6.1.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: factory_bot_rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '6.4'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 6.4.3
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '6.4'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 6.4.3
73
+ - !ruby/object:Gem::Dependency
74
+ name: faker
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.4'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.4.1
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 3.4.1
93
+ description: This gem is designed to work within a larger Rails application, where
94
+ it can be used to dynamically load and manage different blog templates based on
95
+ account settings. It's a key component in creating a flexible, multi-tenant blogging
96
+ platform where different users or accounts can have different looking blogs all
97
+ running on the same underlying system.
98
+ email:
99
+ - carl@wdwhub.net
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - MIT-LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - app/assets/config/bravura_template_base_manifest.js
108
+ - app/assets/stylesheets/bravura_template_base/application.css
109
+ - app/controllers/bravura_template_base/application_controller.rb
110
+ - app/helpers/bravura_template_base/application_helper.rb
111
+ - app/jobs/bravura_template_base/application_job.rb
112
+ - app/mailers/bravura_template_base/application_mailer.rb
113
+ - app/models/bravura_template_base/application_record.rb
114
+ - app/views/layouts/bravura_template_base/application.html.erb
115
+ - config/routes.rb
116
+ - lib/bravura_template_base.rb
117
+ - lib/bravura_template_base/engine.rb
118
+ - lib/bravura_template_base/version.rb
119
+ - lib/tasks/bravura_template_base_tasks.rake
120
+ homepage: https://github.com/yourusername/bravura_template_base
121
+ licenses:
122
+ - MIT
123
+ metadata:
124
+ homepage_uri: https://github.com/yourusername/bravura_template_base
125
+ source_code_uri: https://github.com/yourusername/bravura_template_base
126
+ changelog_uri: https://github.com/yourusername/bravura_template_base/blob/main/CHANGELOG.md
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.5.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Base gem for Bravura blog templates
146
+ test_files: []