serbea-rails 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +12 -0
- data/lib/serbea-rails/directives.rb +36 -0
- data/lib/serbea-rails.rb +51 -0
- data/lib/version.rb +3 -0
- data/serbea.gemspec +25 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 31b233ec3cc8eea4bbaf071dff5e8fef5b4c739330dfde7228e2d3ab3cc702f0
|
4
|
+
data.tar.gz: d99c652509a3d06cfad966c6781c6897761aca7bc29c3bd1b59573167e26ba3b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca92d319961c3e1294ef218defe6a94129ff639fa3b47c1189f61ce3121d83790120b8c74b62b8828ccb6e87d227aae3980108c34ab3a194725f1bfeddc64bfa
|
7
|
+
data.tar.gz: 66c10ba30b052882b6d77ef30223bc4462fe2cc64b603e4e433c71393f336d82c0572142e2117c48259e9def2a7153712408f0fe93b028398382c83d48ff65bb
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present Jared White
|
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/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Serbea::TemplateEngine.directive :form, ->(code, buffer) do
|
2
|
+
model_name, space, params = code.lstrip.partition(%r(\s)m)
|
3
|
+
model_name.chomp!(",")
|
4
|
+
model_name = "#{model_name}," unless params.lstrip.start_with?("do", "{")
|
5
|
+
|
6
|
+
buffer << "{%= form_with model: "
|
7
|
+
buffer << model_name << " #{params}"
|
8
|
+
buffer << " %}"
|
9
|
+
end
|
10
|
+
|
11
|
+
Serbea::TemplateEngine.directive :frame, ->(code, buffer) do
|
12
|
+
buffer << "{%= turbo_frame_tag "
|
13
|
+
buffer << code
|
14
|
+
buffer << " %}"
|
15
|
+
end
|
16
|
+
|
17
|
+
%i(append prepend update replace remove before after).each do |action|
|
18
|
+
Serbea::TemplateEngine.directive action, ->(code, buffer) do
|
19
|
+
buffer << "{%= turbo_stream.#{action} "
|
20
|
+
buffer << code
|
21
|
+
buffer << " %}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Serbea::TemplateEngine.directive :_, ->(code, buffer) do
|
26
|
+
tag_name, space, params = code.lstrip.partition(%r(\s)m)
|
27
|
+
|
28
|
+
if tag_name.end_with?(":")
|
29
|
+
tag_name.chomp!(":")
|
30
|
+
tag_name = ":#{tag_name}" unless tag_name.start_with?(":")
|
31
|
+
end
|
32
|
+
|
33
|
+
buffer << "{%= tag.tag_string "
|
34
|
+
buffer << tag_name << ", " << params
|
35
|
+
buffer << " %}"
|
36
|
+
end
|
data/lib/serbea-rails.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "serbea"
|
4
|
+
require "hash_with_dot_access"
|
5
|
+
|
6
|
+
require "serbea-rails/directives"
|
7
|
+
|
8
|
+
module SerbeaRails
|
9
|
+
module FrontmatterHelpers
|
10
|
+
def set_page_frontmatter=(data)
|
11
|
+
@frontmatter ||= HashWithDotAccess::Hash.new
|
12
|
+
@frontmatter.update(data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module FrontmatterControllerActions
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
Serbea::TemplateEngine.front_matter_preamble = "self.set_page_frontmatter = local_frontmatter = YAML.load"
|
21
|
+
|
22
|
+
before_action { @frontmatter ||= HashWithDotAccess::Hash.new }
|
23
|
+
|
24
|
+
helper SerbeaRails::FrontmatterHelpers
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class TemplateHandler
|
29
|
+
def handles_encoding?; true; end
|
30
|
+
|
31
|
+
def compile(template, source)
|
32
|
+
"self.class.include(Serbea::Helpers);" + Tilt::SerbeaTemplate.new { source }.precompiled_template([])
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.call(template, source = nil)
|
36
|
+
source ||= template.source
|
37
|
+
|
38
|
+
new.compile(template, source)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
ActionView::Template.register_template_handler(:serb, SerbeaRails::TemplateHandler)
|
44
|
+
|
45
|
+
class Railtie < ::Rails::Railtie
|
46
|
+
initializer :serbea do |app|
|
47
|
+
ActiveSupport.on_load(:action_view) do
|
48
|
+
ActionController::Base.include SerbeaRails::FrontmatterControllerActions
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/version.rb
ADDED
data/serbea.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "serbea-rails"
|
7
|
+
spec.version = SerbeaRails::VERSION
|
8
|
+
spec.author = "Bridgetown Team"
|
9
|
+
spec.email = "maintainers@bridgetownrb.com"
|
10
|
+
spec.summary = "Rails plugin for Serbea"
|
11
|
+
spec.homepage = "https://github.com/bridgetownrb/serbea"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.required_ruby_version = ">= 2.7"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features)/!) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency("serbea", ">= 1.0")
|
20
|
+
spec.add_runtime_dependency("activesupport", ">= 6.0")
|
21
|
+
spec.add_runtime_dependency("actionview", ">= 6.0")
|
22
|
+
spec.add_runtime_dependency("hash_with_dot_access", "~> 1.1")
|
23
|
+
|
24
|
+
spec.add_development_dependency("rake", "~> 13.0")
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serbea-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bridgetown Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: serbea
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: actionview
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '6.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hash_with_dot_access
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
83
|
+
description:
|
84
|
+
email: maintainers@bridgetownrb.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- Gemfile
|
90
|
+
- LICENSE.txt
|
91
|
+
- Rakefile
|
92
|
+
- lib/serbea-rails.rb
|
93
|
+
- lib/serbea-rails/directives.rb
|
94
|
+
- lib/version.rb
|
95
|
+
- serbea.gemspec
|
96
|
+
homepage: https://github.com/bridgetownrb/serbea
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '2.7'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubygems_version: 3.1.4
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Rails plugin for Serbea
|
119
|
+
test_files: []
|