frontman-ssg 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +13 -2
  4. data/Rakefile +5 -2
  5. data/frontman-ssg.gemspec +1 -0
  6. data/lib/frontman.rb +0 -5
  7. data/lib/frontman/app.rb +1 -3
  8. data/lib/frontman/builder/file.rb +1 -3
  9. data/lib/frontman/commands/init.rb +2 -3
  10. data/lib/frontman/commands/serve.rb +29 -28
  11. data/lib/frontman/concerns/forward_calls_to_app.rb +1 -1
  12. data/lib/frontman/context.rb +68 -57
  13. data/lib/frontman/data_store.rb +1 -3
  14. data/lib/frontman/iterator.rb +1 -3
  15. data/lib/frontman/renderers/erb_renderer.rb +19 -1
  16. data/lib/frontman/renderers/haml_renderer.rb +29 -1
  17. data/lib/frontman/renderers/renderer_resolver.rb +18 -5
  18. data/lib/frontman/renderers/slim_renderer.rb +30 -0
  19. data/lib/frontman/resource.rb +9 -13
  20. data/lib/frontman/sitemap_tree.rb +1 -3
  21. data/lib/frontman/version.rb +1 -1
  22. data/project-templates/webpack/helpers/assets_helper.rb +1 -3
  23. data/sorbet/rbi/gems/ast.rbi +48 -0
  24. data/sorbet/rbi/gems/better_errors.rbi +180 -0
  25. data/sorbet/rbi/gems/binding_of_caller.rbi +23 -0
  26. data/sorbet/rbi/gems/coderay.rbi +24 -0
  27. data/sorbet/rbi/gems/debug_inspector.rbi +19 -0
  28. data/sorbet/rbi/gems/docile.rbi +32 -0
  29. data/sorbet/rbi/gems/dotenv.rbi +68 -0
  30. data/sorbet/rbi/gems/erubi.rbi +27 -0
  31. data/sorbet/rbi/gems/erubis.rbi +280 -0
  32. data/sorbet/rbi/gems/haml.rbi +521 -0
  33. data/sorbet/rbi/gems/htmlentities.rbi +46 -0
  34. data/sorbet/rbi/gems/jaro_winkler.rbi +15 -0
  35. data/sorbet/rbi/gems/kramdown-parser-gfm.rbi +29 -0
  36. data/sorbet/rbi/gems/kramdown.rbi +338 -0
  37. data/sorbet/rbi/gems/listen.rbi +301 -0
  38. data/sorbet/rbi/gems/mustermann.rbi +481 -0
  39. data/sorbet/rbi/gems/nokogiri.rbi +1011 -0
  40. data/sorbet/rbi/gems/parallel.rbi +82 -0
  41. data/sorbet/rbi/gems/parser.rbi +1405 -0
  42. data/sorbet/rbi/gems/rack-protection.rbi +16 -0
  43. data/sorbet/rbi/gems/rack.rbi +507 -0
  44. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  45. data/sorbet/rbi/gems/rake.rbi +641 -0
  46. data/sorbet/rbi/gems/rexml.rbi +93 -0
  47. data/sorbet/rbi/gems/rouge.rbi +1551 -0
  48. data/sorbet/rbi/gems/rspec-core.rbi +1893 -0
  49. data/sorbet/rbi/gems/rspec-expectations.rbi +1125 -0
  50. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  51. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  52. data/sorbet/rbi/gems/rspec.rbi +15 -0
  53. data/sorbet/rbi/gems/rubocop-performance.rbi +274 -0
  54. data/sorbet/rbi/gems/rubocop.rbi +7403 -0
  55. data/sorbet/rbi/gems/ruby-progressbar.rbi +305 -0
  56. data/sorbet/rbi/gems/ruby2_keywords.rbi +17 -0
  57. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  58. data/sorbet/rbi/gems/simplecov.rbi +405 -0
  59. data/sorbet/rbi/gems/sinatra.rbi +488 -0
  60. data/sorbet/rbi/gems/slim.rbi +144 -0
  61. data/sorbet/rbi/gems/temple.rbi +281 -0
  62. data/sorbet/rbi/gems/thor.rbi +522 -0
  63. data/sorbet/rbi/gems/tilt.rbi +82 -0
  64. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  65. data/sorbet/rbi/gems/yaml-front-matter.rbi +16 -0
  66. data/sorbet/rbi/hidden-definitions/errors.txt +2859 -24228
  67. data/sorbet/rbi/hidden-definitions/hidden.rbi +7111 -40830
  68. data/sorbet/rbi/sorbet-typed/lib/nokogiri/1.10.10/nokogiri.rbi +1615 -0
  69. data/sorbet/rbi/sorbet-typed/lib/thor/all/thor.rbi +905 -0
  70. data/sorbet/rbi/todo.rbi +6 -0
  71. data/spec/frontman/bootstrapper_spec.rb +1 -1
  72. data/spec/frontman/context_spec.rb +45 -6
  73. data/spec/frontman/mocks/context.haml +18 -0
  74. data/spec/frontman/renderers/slim_renderer_spec.rb +12 -0
  75. metadata +66 -4
@@ -1,8 +1,10 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'frontman/renderers/renderer'
4
5
  require 'frontman/renderers/erb_renderer'
5
6
  require 'frontman/renderers/haml_renderer'
7
+ require 'frontman/renderers/slim_renderer'
6
8
  require 'frontman/renderers/markdown_renderer'
7
9
  require 'singleton'
8
10
  require 'sorbet-runtime'
@@ -14,13 +16,24 @@ module Frontman
14
16
 
15
17
  sig { params(extension: String).returns(T.nilable(Frontman::Renderer)) }
16
18
  def get_renderer(extension)
17
- renderers = {
18
- 'erb': Frontman::ErbRenderer.instance,
19
- 'md': Frontman::MarkdownRenderer.instance,
20
- 'haml': Frontman::HamlRenderer.instance
19
+ all_renderers[extension.to_sym]
20
+ end
21
+
22
+ sig { returns(T::Hash[Symbol, Frontman::Renderer]) }
23
+ def all_renderers
24
+ @all_renderers ||= {
25
+ erb: Frontman::ErbRenderer.instance,
26
+ md: Frontman::MarkdownRenderer.instance,
27
+ haml: Frontman::HamlRenderer.instance,
28
+ slim: Frontman::SlimRenderer.instance
21
29
  }
30
+ end
22
31
 
23
- renderers[extension.to_sym]
32
+ sig { params(extension: String).returns(T::Boolean) }
33
+ def valid_extension?(extension)
34
+ # We have to append html and txt manually here
35
+ # so we can extract front matter data from them
36
+ all_renderers.keys.push(:html, :txt).include?(extension.to_sym)
24
37
  end
25
38
  end
26
39
  end
@@ -0,0 +1,30 @@
1
+ # typed: false
2
+ # frozen_string_literal: false
3
+
4
+ require 'slim'
5
+ require 'frontman/renderers/renderer'
6
+
7
+ module Frontman
8
+ class SlimRenderer < Renderer
9
+ def initialize
10
+ Slim::Engine.set_options(
11
+ pretty: true,
12
+ buffer: :@_slim_buffer,
13
+ sort_attrs: false,
14
+ disable_escape: true
15
+ )
16
+
17
+ super
18
+ end
19
+
20
+ def compile(layout)
21
+ Slim::Template.new(nil) do
22
+ layout
23
+ end
24
+ end
25
+
26
+ def render_content(compiled, content, scope, _data)
27
+ compiled.render(scope) { content }
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,4 @@
1
- # typed: true
1
+ # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'frontman/renderers/renderer_resolver'
@@ -65,18 +65,16 @@ module Frontman
65
65
  @destination_path
66
66
  )
67
67
 
68
- if destination_without_extension == 'index'
69
- destination_without_extension = ''
70
- end
68
+ destination_without_extension = '' if destination_without_extension == 'index'
71
69
 
72
70
  is_index_page = destination_without_extension.end_with?('/index')
73
71
  @extension = dest_file_extensions.first
74
72
 
75
- if (@extension == 'html' || extension.nil?) && !is_index_page
76
- @destination_path = destination_without_extension + '/index.html'
77
- else
78
- @destination_path = destination_without_extension + '.' + @extension
79
- end
73
+ @destination_path = if (@extension == 'html' || extension.nil?) && !is_index_page
74
+ destination_without_extension + '/index.html'
75
+ else
76
+ destination_without_extension + '.' + @extension
77
+ end
80
78
  @path = "/#{@destination_path.chomp('index.html')}"
81
79
  .gsub('//', '/')
82
80
  end
@@ -106,7 +104,7 @@ module Frontman
106
104
  @content = File.read(@file_path)
107
105
  @data = {}.to_ostruct
108
106
 
109
- if %w[erb html haml md txt].include?(@extension)
107
+ if Frontman::RendererResolver.instance.valid_extension?(@extension)
110
108
  @data, @content = YAML::FrontMatter.extract(@content).to_ostruct
111
109
  end
112
110
 
@@ -168,9 +166,7 @@ module Frontman
168
166
 
169
167
  # If we have no layout to render and already cache the rendered content
170
168
  # we can return it directly
171
- if layout_from_extra_data.nil? && !@rendered_content.nil?
172
- return @rendered_content
173
- end
169
+ return @rendered_content if layout_from_extra_data.nil? && !@rendered_content.nil?
174
170
 
175
171
  content = @content
176
172
 
@@ -40,9 +40,7 @@ module Frontman
40
40
  raise DuplicateResourceError.create(resource, url, existing_resource)
41
41
  end
42
42
 
43
- if Frontman::App.instance.get_redirect(url)
44
- raise ExistingRedirectError.create(resource, url)
45
- end
43
+ raise ExistingRedirectError.create(resource, url) if Frontman::App.instance.get_redirect(url)
46
44
 
47
45
  SitemapTree.resources.push(resource)
48
46
  parts = url.split('/')
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Frontman
4
4
  # Current Version
5
- VERSION = '0.0.4'
5
+ VERSION = '0.1.0'
6
6
  end
@@ -8,9 +8,7 @@ module AssetsHelper
8
8
  end
9
9
 
10
10
  def vendor_scripts_by_chunk(chunk, scripts)
11
- if chunk == 'vendors'
12
- raise ChunkNameError, '"vendors" is an invalid chunk name'
13
- end
11
+ raise ChunkNameError, '"vendors" is an invalid chunk name' if chunk == 'vendors'
14
12
 
15
13
  pattern = /.*~#{chunk}.*|.*#{chunk}~.*$/
16
14
 
@@ -0,0 +1,48 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: strict
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/ast/all/ast.rbi
9
+ #
10
+ # ast-2.4.1
11
+
12
+ module AST
13
+ end
14
+ class AST::Node
15
+ def +(array); end
16
+ def <<(element); end
17
+ def ==(other); end
18
+ def append(element); end
19
+ def assign_properties(properties); end
20
+ def children; end
21
+ def clone; end
22
+ def concat(array); end
23
+ def dup; end
24
+ def eql?(other); end
25
+ def fancy_type; end
26
+ def hash; end
27
+ def initialize(type, children = nil, properties = nil); end
28
+ def inspect(indent = nil); end
29
+ def original_dup; end
30
+ def to_a; end
31
+ def to_ast; end
32
+ def to_s(indent = nil); end
33
+ def to_sexp(indent = nil); end
34
+ def to_sexp_array; end
35
+ def type; end
36
+ def updated(type = nil, children = nil, properties = nil); end
37
+ end
38
+ class AST::Processor
39
+ include AST::Processor::Mixin
40
+ end
41
+ module AST::Processor::Mixin
42
+ def handler_missing(node); end
43
+ def process(node); end
44
+ def process_all(nodes); end
45
+ end
46
+ module AST::Sexp
47
+ def s(type, *children); end
48
+ end
@@ -0,0 +1,180 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: strict
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/better_errors/all/better_errors.rbi
9
+ #
10
+ # better_errors-2.9.1
11
+
12
+ module BetterErrors
13
+ def self.application_root; end
14
+ def self.application_root=(arg0); end
15
+ def self.binding_of_caller_available; end
16
+ def self.binding_of_caller_available=(arg0); end
17
+ def self.binding_of_caller_available?; end
18
+ def self.default_editor; end
19
+ def self.editor; end
20
+ def self.editor=(editor); end
21
+ def self.ignored_classes; end
22
+ def self.ignored_classes=(arg0); end
23
+ def self.ignored_instance_variables; end
24
+ def self.ignored_instance_variables=(arg0); end
25
+ def self.logger; end
26
+ def self.logger=(arg0); end
27
+ def self.maximum_variable_inspect_size; end
28
+ def self.maximum_variable_inspect_size=(arg0); end
29
+ def self.use_pry!; end
30
+ end
31
+ class BetterErrors::CodeFormatter::HTML < BetterErrors::CodeFormatter
32
+ def formatted_code; end
33
+ def formatted_lines; end
34
+ def formatted_nums; end
35
+ def source_unavailable; end
36
+ end
37
+ class BetterErrors::CodeFormatter::Text < BetterErrors::CodeFormatter
38
+ def formatted_lines; end
39
+ def source_unavailable; end
40
+ end
41
+ class BetterErrors::CodeFormatter
42
+ def coderay_scanner; end
43
+ def context; end
44
+ def context_lines; end
45
+ def each_line_of(lines, &blk); end
46
+ def filename; end
47
+ def formatted_code; end
48
+ def highlighted_lines; end
49
+ def initialize(filename, line, context = nil); end
50
+ def line; end
51
+ def line_range; end
52
+ def output; end
53
+ def source_lines; end
54
+ end
55
+ class BetterErrors::ValueLargerThanConfiguredMaximum < StandardError
56
+ end
57
+ class BetterErrors::InspectableValue
58
+ def initialize(value); end
59
+ def original_value; end
60
+ def to_html; end
61
+ def value; end
62
+ def value_as_html; end
63
+ def value_small_enough_to_inspect?; end
64
+ end
65
+ class BetterErrors::ErrorPage
66
+ def action_dispatch_action_endpoint; end
67
+ def active_support_actions; end
68
+ def application_frames; end
69
+ def backtrace_frames; end
70
+ def do_eval(opts); end
71
+ def do_variables(opts); end
72
+ def editor_url(frame); end
73
+ def env; end
74
+ def eval_and_respond(index, code); end
75
+ def exception; end
76
+ def exception_hint; end
77
+ def exception_message; end
78
+ def exception_type; end
79
+ def first_frame; end
80
+ def html_formatted_code_block(frame); end
81
+ def id; end
82
+ def initialize(exception, env); end
83
+ def inspect_value(obj); end
84
+ def rack_session; end
85
+ def rails_params; end
86
+ def render(template_name = nil, csrf_token = nil); end
87
+ def repls; end
88
+ def request_path; end
89
+ def self.template(template_name); end
90
+ def self.template_path(template_name); end
91
+ def text_formatted_code_block(frame); end
92
+ def text_heading(char, str); end
93
+ def uri_prefix; end
94
+ end
95
+ class BetterErrors::Middleware
96
+ def allow_ip?(env); end
97
+ def backtrace_frames; end
98
+ def better_errors_call(env); end
99
+ def call(env); end
100
+ def initialize(app, handler = nil); end
101
+ def internal_call(env, id, method); end
102
+ def invalid_csrf_token_json_response; end
103
+ def invalid_error_json_response; end
104
+ def log_exception; end
105
+ def no_errors_json_response; end
106
+ def no_errors_page; end
107
+ def not_acceptable_json_response; end
108
+ def not_found_json_response; end
109
+ def protected_app_call(env); end
110
+ def self.allow_ip!(addr); end
111
+ def show_error_page(env, exception = nil); end
112
+ def text?(env); end
113
+ end
114
+ class BetterErrors::ExceptionHint
115
+ def exception; end
116
+ def hint; end
117
+ def initialize(exception); end
118
+ end
119
+ class BetterErrors::RaisedException
120
+ def backtrace; end
121
+ def exception; end
122
+ def has_bindings?; end
123
+ def hint; end
124
+ def initialize(exception); end
125
+ def massage_syntax_error; end
126
+ def message; end
127
+ def setup_backtrace; end
128
+ def setup_backtrace_from_backtrace; end
129
+ def setup_backtrace_from_bindings; end
130
+ def setup_hint; end
131
+ def type; end
132
+ end
133
+ module BetterErrors::REPL
134
+ def self.detect; end
135
+ def self.provider; end
136
+ def self.provider=(prov); end
137
+ def self.test_provider(provider); end
138
+ end
139
+ class BetterErrors::StackFrame
140
+ def application?; end
141
+ def application_path; end
142
+ def class_name; end
143
+ def context; end
144
+ def eval_local_variable(name); end
145
+ def filename; end
146
+ def frame_binding; end
147
+ def gem?; end
148
+ def gem_path; end
149
+ def get_local_variable(name); end
150
+ def initialize(filename, line, name, frame_binding = nil); end
151
+ def instance_variables; end
152
+ def line; end
153
+ def local_variable(name); end
154
+ def local_variables; end
155
+ def method_name; end
156
+ def name; end
157
+ def pretty_path; end
158
+ def self.from_exception(exception); end
159
+ def set_pretty_method_name; end
160
+ def to_s; end
161
+ def visible_instance_variables; end
162
+ end
163
+ class BetterErrors::Editor
164
+ def host_path; end
165
+ def initialize(url_proc); end
166
+ def self.default_editor; end
167
+ def self.editor_from_command(editor_command); end
168
+ def self.editor_from_environment_editor; end
169
+ def self.editor_from_environment_formatting_string; end
170
+ def self.editor_from_symbol(symbol); end
171
+ def self.for_formatting_string(formatting_string); end
172
+ def self.for_proc(url_proc); end
173
+ def url(raw_path, line); end
174
+ def url_proc; end
175
+ def virtual_path; end
176
+ end
177
+ module BetterErrors::ExceptionExtension
178
+ def __better_errors_bindings_stack; end
179
+ def set_backtrace(*arg0); end
180
+ end
@@ -0,0 +1,23 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: strict
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/binding_of_caller/all/binding_of_caller.rbi
9
+ #
10
+ # binding_of_caller-0.8.0
11
+
12
+ module BindingOfCaller
13
+ end
14
+ module BindingOfCaller::BindingExtensions
15
+ def callers; end
16
+ def frame_count; end
17
+ def frame_description; end
18
+ def frame_type; end
19
+ def of_caller(n); end
20
+ end
21
+ class Binding
22
+ include BindingOfCaller::BindingExtensions
23
+ end
@@ -0,0 +1,24 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: strict
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/coderay/all/coderay.rbi
9
+ #
10
+ # coderay-1.1.3
11
+
12
+ module CodeRay
13
+ def self.coderay_path(*path); end
14
+ def self.encode(code, lang, format, options = nil); end
15
+ def self.encode_file(filename, format, options = nil); end
16
+ def self.encode_tokens(tokens, format, options = nil); end
17
+ def self.encoder(format, options = nil); end
18
+ def self.get_scanner_options(options); end
19
+ def self.highlight(code, lang, options = nil, format = nil); end
20
+ def self.highlight_file(filename, options = nil, format = nil); end
21
+ def self.scan(code, lang, options = nil, &block); end
22
+ def self.scan_file(filename, lang = nil, options = nil, &block); end
23
+ def self.scanner(lang, options = nil, &block); end
24
+ end
@@ -0,0 +1,19 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: strict
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/debug_inspector/all/debug_inspector.rbi
9
+ #
10
+ # debug_inspector-0.0.3
11
+
12
+ class RubyVM::DebugInspector
13
+ def backtrace_locations; end
14
+ def frame_binding(arg0); end
15
+ def frame_class(arg0); end
16
+ def frame_iseq(arg0); end
17
+ def frame_self(arg0); end
18
+ def self.open; end
19
+ end