serbea 0.11.4 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +30 -0
- data/lib/{serbea/rouge_lexer.rb → rouge/lexers/serbea.rb} +2 -1
- data/lib/serbea/helpers.rb +11 -7
- data/lib/serbea/pipeline.rb +5 -21
- data/lib/serbea.rb +0 -16
- data/lib/version.rb +1 -1
- data/serbea.gemspec +3 -4
- metadata +12 -53
- data/docs/.gitignore +0 -37
- data/docs/Gemfile +0 -5
- data/docs/bridgetown.config.yml +0 -6
- data/docs/frontend/javascript/index.js +0 -3
- data/docs/frontend/styles/index.scss +0 -169
- data/docs/package.json +0 -34
- data/docs/plugins/builders/.keep +0 -0
- data/docs/plugins/site_builder.rb +0 -3
- data/docs/src/404.html +0 -9
- data/docs/src/_components/footer.liquid +0 -3
- data/docs/src/_components/head.liquid +0 -9
- data/docs/src/_components/navbar.liquid +0 -5
- data/docs/src/_data/site_metadata.yml +0 -11
- data/docs/src/_layouts/default.liquid +0 -13
- data/docs/src/_layouts/home.liquid +0 -13
- data/docs/src/_layouts/page.liquid +0 -7
- data/docs/src/_layouts/post.liquid +0 -7
- data/docs/src/favicon.ico +0 -0
- data/docs/src/images/.keep +0 -1
- data/docs/src/images/serbea-logomark.svg +0 -46
- data/docs/src/images/serbea-logotype.svg +0 -31
- data/docs/src/index.md +0 -264
- data/docs/start.js +0 -17
- data/docs/sync.js +0 -35
- data/docs/webpack.config.js +0 -78
- data/docs/yarn.lock +0 -6022
- data/lib/serbea/bridgetown_support.rb +0 -68
- data/lib/serbea/rails_support.rb +0 -79
@@ -1,68 +0,0 @@
|
|
1
|
-
require "serbea/rouge_lexer"
|
2
|
-
require "bridgetown-core"
|
3
|
-
|
4
|
-
module Bridgetown
|
5
|
-
class SerbeaView < ERBView
|
6
|
-
include Serbea::Helpers
|
7
|
-
|
8
|
-
def partial(partial_name, options = {}, &block)
|
9
|
-
options.merge!(options[:locals]) if options[:locals]
|
10
|
-
options[:content] = capture(&block) if block
|
11
|
-
|
12
|
-
partial_segments = partial_name.split("/")
|
13
|
-
partial_segments.last.sub!(%r!^!, "_")
|
14
|
-
partial_name = partial_segments.join("/")
|
15
|
-
|
16
|
-
Tilt::SerbeaTemplate.new(
|
17
|
-
site.in_source_dir(site.config[:partials_dir], "#{partial_name}.serb")
|
18
|
-
).render(self, options)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Converters
|
23
|
-
class SerbeaTemplates < Converter
|
24
|
-
priority :highest
|
25
|
-
input :serb
|
26
|
-
|
27
|
-
# Logic to do the Serbea content conversion.
|
28
|
-
#
|
29
|
-
# @param content [String] Content of the file (without front matter).
|
30
|
-
# @param convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]
|
31
|
-
# The instantiated object which is processing the file.
|
32
|
-
#
|
33
|
-
# @return [String] The converted content.
|
34
|
-
def convert(content, convertible)
|
35
|
-
return content if convertible.data[:template_engine] != "serbea"
|
36
|
-
|
37
|
-
serb_view = Bridgetown::SerbeaView.new(convertible)
|
38
|
-
|
39
|
-
serb_renderer = Tilt::SerbeaTemplate.new(convertible.relative_path) { content }
|
40
|
-
|
41
|
-
if convertible.is_a?(Bridgetown::Layout)
|
42
|
-
serb_renderer.render(serb_view) do
|
43
|
-
convertible.current_document_output
|
44
|
-
end
|
45
|
-
else
|
46
|
-
serb_renderer.render(serb_view)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def matches(ext, convertible)
|
51
|
-
if convertible.data[:template_engine] == "serbea" ||
|
52
|
-
(convertible.data[:template_engine].nil? &&
|
53
|
-
@config[:template_engine] == "serbea")
|
54
|
-
convertible.data[:template_engine] = "serbea"
|
55
|
-
return true
|
56
|
-
end
|
57
|
-
|
58
|
-
super(ext).tap do |ext_matches|
|
59
|
-
convertible.data[:template_engine] = "serbea" if ext_matches
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def output_ext(ext)
|
64
|
-
ext == ".serb" ? ".html" : ext
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/serbea/rails_support.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hash_with_dot_access"
|
4
|
-
|
5
|
-
module Serbea
|
6
|
-
module Rails
|
7
|
-
module FrontmatterHelpers
|
8
|
-
def set_page_frontmatter=(data)
|
9
|
-
@frontmatter ||= HashWithDotAccess::Hash.new
|
10
|
-
@frontmatter.update(data)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module FrontmatterControllerActions
|
15
|
-
extend ActiveSupport::Concern
|
16
|
-
|
17
|
-
included do
|
18
|
-
Serbea::TemplateEngine.front_matter_preamble = "self.set_page_frontmatter = local_frontmatter = YAML.load"
|
19
|
-
|
20
|
-
before_action { @frontmatter ||= HashWithDotAccess::Hash.new }
|
21
|
-
|
22
|
-
helper Serbea::Rails::FrontmatterHelpers
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class TemplateHandler
|
27
|
-
def handles_encoding?; true; end
|
28
|
-
|
29
|
-
def compile(template, source)
|
30
|
-
"self.class.include(Serbea::Helpers);" + Tilt::SerbeaTemplate.new { source }.precompiled_template([])
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.call(template, source = nil)
|
34
|
-
source ||= template.source
|
35
|
-
|
36
|
-
new.compile(template, source)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Serbea::TemplateEngine.directive :form, ->(code, buffer) do
|
43
|
-
model_name, space, params = code.lstrip.partition(%r(\s)m)
|
44
|
-
model_name.chomp!(",")
|
45
|
-
model_name = "#{model_name}," unless params.lstrip.start_with?("do", "{")
|
46
|
-
|
47
|
-
buffer << "{%= form_with model: "
|
48
|
-
buffer << model_name << " #{params}"
|
49
|
-
buffer << " %}"
|
50
|
-
end
|
51
|
-
|
52
|
-
Serbea::TemplateEngine.directive :frame, ->(code, buffer) do
|
53
|
-
buffer << "{%= turbo_frame_tag "
|
54
|
-
buffer << code
|
55
|
-
buffer << " %}"
|
56
|
-
end
|
57
|
-
|
58
|
-
%i(append prepend update replace remove).each do |action|
|
59
|
-
Serbea::TemplateEngine.directive action, ->(code, buffer) do
|
60
|
-
buffer << "{%= turbo_stream.#{action} "
|
61
|
-
buffer << code
|
62
|
-
buffer << " %}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
Serbea::TemplateEngine.directive :_, ->(code, buffer) do
|
67
|
-
tag_name, space, params = code.lstrip.partition(%r(\s)m)
|
68
|
-
|
69
|
-
if tag_name.end_with?(":")
|
70
|
-
tag_name.chomp!(":")
|
71
|
-
tag_name = ":#{tag_name}" unless tag_name.start_with?(":")
|
72
|
-
end
|
73
|
-
|
74
|
-
buffer << "{%= tag.tag_string "
|
75
|
-
buffer << tag_name << ", " << params
|
76
|
-
buffer << " %}"
|
77
|
-
end
|
78
|
-
|
79
|
-
ActionView::Template.register_template_handler(:serb, Serbea::Rails::TemplateHandler)
|