nanoc 4.11.12 → 4.11.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +788 -743
- data/bin/nanoc +1 -1
- data/lib/nanoc.rb +6 -29
- data/lib/nanoc/data_sources/filesystem.rb +9 -3
- data/lib/nanoc/data_sources/filesystem/tools.rb +4 -4
- data/lib/nanoc/extra.rb +2 -1
- data/lib/nanoc/extra/core_ext.rb +0 -1
- data/lib/nanoc/extra/srcset_parser.rb +79 -0
- data/lib/nanoc/filters/colorize_syntax/colorizers.rb +1 -1
- data/lib/nanoc/filters/erb.rb +1 -5
- data/lib/nanoc/filters/relativize_paths.rb +62 -10
- data/lib/nanoc/filters/sass/functions.rb +1 -1
- data/lib/nanoc/helpers/blogging.rb +8 -8
- data/lib/nanoc/helpers/capturing.rb +1 -1
- data/lib/nanoc/helpers/link_to.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +5 -4
- data/lib/nanoc/orig_cli.rb +15 -0
- data/lib/nanoc/{cli → orig_cli}/commands/show-rules.rb +3 -3
- data/lib/nanoc/rule_dsl.rb +1 -0
- data/lib/nanoc/rule_dsl/action_provider.rb +6 -6
- data/lib/nanoc/rule_dsl/action_recorder.rb +4 -4
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
- data/lib/nanoc/rule_dsl/compiler_dsl.rb +2 -2
- data/lib/nanoc/rule_dsl/errors.rb +25 -0
- data/lib/nanoc/rule_dsl/rule_context.rb +6 -6
- data/lib/nanoc/rule_dsl/rules_loader.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- metadata +23 -158
- data/lib/nanoc/base.rb +0 -16
- data/lib/nanoc/base/changes_stream.rb +0 -53
- data/lib/nanoc/base/error.rb +0 -7
- data/lib/nanoc/base/errors.rb +0 -163
- data/lib/nanoc/base/feature.rb +0 -104
- data/lib/nanoc/base/repos.rb +0 -4
- data/lib/nanoc/base/repos/config_loader.rb +0 -95
- data/lib/nanoc/base/repos/site_loader.rb +0 -102
- data/lib/nanoc/base/services.rb +0 -23
- data/lib/nanoc/base/services/compiler.rb +0 -214
- data/lib/nanoc/base/services/compiler/phases.rb +0 -19
- data/lib/nanoc/base/services/compiler/phases/abstract.rb +0 -50
- data/lib/nanoc/base/services/compiler/phases/cache.rb +0 -45
- data/lib/nanoc/base/services/compiler/phases/mark_done.rb +0 -25
- data/lib/nanoc/base/services/compiler/phases/notify.rb +0 -21
- data/lib/nanoc/base/services/compiler/phases/recalculate.rb +0 -51
- data/lib/nanoc/base/services/compiler/phases/resume.rb +0 -54
- data/lib/nanoc/base/services/compiler/phases/write.rb +0 -86
- data/lib/nanoc/base/services/compiler/stages.rb +0 -23
- data/lib/nanoc/base/services/compiler/stages/build_reps.rb +0 -38
- data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +0 -44
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +0 -45
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +0 -98
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +0 -51
- data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +0 -22
- data/lib/nanoc/base/services/compiler/stages/load_stores.rb +0 -37
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +0 -23
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +0 -34
- data/lib/nanoc/base/services/compiler/stages/prune.rb +0 -32
- data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +0 -22
- data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +0 -34
- data/lib/nanoc/base/services/compiler_loader.rb +0 -48
- data/lib/nanoc/base/services/executor.rb +0 -134
- data/lib/nanoc/base/services/filter.rb +0 -267
- data/lib/nanoc/base/services/item_rep_builder.rb +0 -54
- data/lib/nanoc/base/services/item_rep_selector.rb +0 -69
- data/lib/nanoc/base/services/item_rep_writer.rb +0 -86
- data/lib/nanoc/base/services/outdatedness_checker.rb +0 -222
- data/lib/nanoc/base/services/outdatedness_rules.rb +0 -18
- data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +0 -41
- data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +0 -31
- data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +0 -21
- data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +0 -20
- data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +0 -20
- data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +0 -17
- data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +0 -45
- data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +0 -26
- data/lib/nanoc/base/services/pruner.rb +0 -123
- data/lib/nanoc/base/views.rb +0 -40
- data/lib/nanoc/base/views/basic_item_rep_collection_view.rb +0 -86
- data/lib/nanoc/base/views/basic_item_rep_view.rb +0 -81
- data/lib/nanoc/base/views/basic_item_view.rb +0 -52
- data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +0 -10
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +0 -49
- data/lib/nanoc/base/views/compilation_item_view.rb +0 -45
- data/lib/nanoc/base/views/config_view.rb +0 -68
- data/lib/nanoc/base/views/identifiable_collection_view.rb +0 -109
- data/lib/nanoc/base/views/item_collection_with_reps_view.rb +0 -10
- data/lib/nanoc/base/views/item_collection_without_reps_view.rb +0 -10
- data/lib/nanoc/base/views/layout_collection_view.rb +0 -10
- data/lib/nanoc/base/views/layout_view.rb +0 -7
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +0 -88
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +0 -58
- data/lib/nanoc/base/views/mutable_config_view.rb +0 -14
- data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +0 -17
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +0 -32
- data/lib/nanoc/base/views/mutable_item_view.rb +0 -7
- data/lib/nanoc/base/views/mutable_layout_collection_view.rb +0 -24
- data/lib/nanoc/base/views/mutable_layout_view.rb +0 -7
- data/lib/nanoc/base/views/post_compile_item_collection_view.rb +0 -10
- data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +0 -10
- data/lib/nanoc/base/views/post_compile_item_rep_view.rb +0 -31
- data/lib/nanoc/base/views/post_compile_item_view.rb +0 -18
- data/lib/nanoc/base/views/view.rb +0 -41
- data/lib/nanoc/checking.rb +0 -14
- data/lib/nanoc/checking/check.rb +0 -93
- data/lib/nanoc/checking/checks.rb +0 -14
- data/lib/nanoc/checking/checks/css.rb +0 -16
- data/lib/nanoc/checking/checks/external_links.rb +0 -151
- data/lib/nanoc/checking/checks/html.rb +0 -16
- data/lib/nanoc/checking/checks/internal_links.rb +0 -95
- data/lib/nanoc/checking/checks/mixed_content.rb +0 -37
- data/lib/nanoc/checking/checks/stale.rb +0 -41
- data/lib/nanoc/checking/checks/w3c_validator.rb +0 -31
- data/lib/nanoc/checking/dsl.rb +0 -27
- data/lib/nanoc/checking/issue.rb +0 -16
- data/lib/nanoc/checking/loader.rb +0 -50
- data/lib/nanoc/checking/runner.rb +0 -136
- data/lib/nanoc/cli.rb +0 -241
- data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -28
- data/lib/nanoc/cli/cleaning_stream.rb +0 -160
- data/lib/nanoc/cli/command_runner.rb +0 -72
- data/lib/nanoc/cli/commands/check.rb +0 -43
- data/lib/nanoc/cli/commands/compile.rb +0 -57
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +0 -58
- data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +0 -50
- data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +0 -100
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +0 -101
- data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +0 -76
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +0 -170
- data/lib/nanoc/cli/commands/create-site.rb +0 -257
- data/lib/nanoc/cli/commands/deploy.rb +0 -126
- data/lib/nanoc/cli/commands/nanoc.rb +0 -42
- data/lib/nanoc/cli/commands/prune.rb +0 -49
- data/lib/nanoc/cli/commands/shell.rb +0 -57
- data/lib/nanoc/cli/commands/show-data.rb +0 -185
- data/lib/nanoc/cli/commands/show-plugins.rb +0 -89
- data/lib/nanoc/cli/commands/view.rb +0 -68
- data/lib/nanoc/cli/error_handler.rb +0 -365
- data/lib/nanoc/cli/logger.rb +0 -75
- data/lib/nanoc/cli/stack_trace_writer.rb +0 -50
- data/lib/nanoc/cli/stream_cleaners.rb +0 -10
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -21
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -13
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -17
- data/lib/nanoc/cli/transform.rb +0 -16
- data/lib/nanoc/deploying.rb +0 -10
- data/lib/nanoc/deploying/deployer.rb +0 -45
- data/lib/nanoc/deploying/deployers.rb +0 -11
- data/lib/nanoc/deploying/deployers/fog.rb +0 -220
- data/lib/nanoc/deploying/deployers/git.rb +0 -112
- data/lib/nanoc/deploying/deployers/rsync.rb +0 -68
- data/lib/nanoc/extra/core_ext/pathname.rb +0 -27
- data/lib/nanoc/spec.rb +0 -240
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class DetermineOutdatedness < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(reps:, outdatedness_checker:, outdatedness_store:)
|
11
|
-
@reps = reps
|
12
|
-
@outdatedness_checker = outdatedness_checker
|
13
|
-
@outdatedness_store = outdatedness_store
|
14
|
-
end
|
15
|
-
|
16
|
-
contract C::None => C::Any
|
17
|
-
def run
|
18
|
-
outdated_items = select_outdated_items
|
19
|
-
outdated_reps = reps_of_items(outdated_items)
|
20
|
-
|
21
|
-
store_outdated_reps(outdated_reps)
|
22
|
-
|
23
|
-
outdated_items
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def store_outdated_reps(reps)
|
29
|
-
@outdatedness_store.clear
|
30
|
-
reps.each { |r| @outdatedness_store.add(r) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def select_outdated_items
|
34
|
-
@reps
|
35
|
-
.select { |r| outdated?(r) }
|
36
|
-
.map(&:item)
|
37
|
-
.uniq
|
38
|
-
end
|
39
|
-
|
40
|
-
def reps_of_items(items)
|
41
|
-
Set.new(items.flat_map { |i| @reps[i] })
|
42
|
-
end
|
43
|
-
|
44
|
-
def outdated?(rep)
|
45
|
-
@outdatedness_store.include?(rep) || @outdatedness_checker.outdated?(rep)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class ForgetOutdatedDependencies < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(dependency_store:)
|
11
|
-
@dependency_store = dependency_store
|
12
|
-
end
|
13
|
-
|
14
|
-
contract C::IterOf[Nanoc::Core::Item] => C::Any
|
15
|
-
def run(outdated_items)
|
16
|
-
outdated_items.each { |i| @dependency_store.forget_dependencies_for(i) }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class LoadStores < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(checksum_store:, compiled_content_cache:, dependency_store:, action_sequence_store:, outdatedness_store:)
|
11
|
-
@checksum_store = checksum_store
|
12
|
-
@compiled_content_cache = compiled_content_cache
|
13
|
-
@dependency_store = dependency_store
|
14
|
-
@action_sequence_store = action_sequence_store
|
15
|
-
@outdatedness_store = outdatedness_store
|
16
|
-
end
|
17
|
-
|
18
|
-
contract C::None => C::Any
|
19
|
-
def run
|
20
|
-
load_store(@checksum_store)
|
21
|
-
load_store(@compiled_content_cache)
|
22
|
-
load_store(@dependency_store)
|
23
|
-
load_store(@action_sequence_store)
|
24
|
-
load_store(@outdatedness_store)
|
25
|
-
end
|
26
|
-
|
27
|
-
contract Nanoc::Core::Store => C::Any
|
28
|
-
def load_store(store)
|
29
|
-
Nanoc::Core::Instrumentor.call(:store_loaded, store.class) do
|
30
|
-
store.load
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class Postprocess < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(action_provider:, site:)
|
11
|
-
@action_provider = action_provider
|
12
|
-
@site = site
|
13
|
-
end
|
14
|
-
|
15
|
-
contract Nanoc::Int::Compiler => C::Any
|
16
|
-
def run(compiler)
|
17
|
-
@action_provider.postprocess(@site, compiler)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class Preprocess < Nanoc::Core::CompilationStage
|
8
|
-
def initialize(action_provider:, site:, dependency_store:, checksum_store:)
|
9
|
-
@action_provider = action_provider
|
10
|
-
@site = site
|
11
|
-
@dependency_store = dependency_store
|
12
|
-
@checksum_store = checksum_store
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
return if @site.preprocessed?
|
17
|
-
|
18
|
-
if @action_provider.need_preprocessing?
|
19
|
-
@site.data_source = Nanoc::Core::InMemoryDataSource.new(@site.items, @site.layouts, @site.data_source)
|
20
|
-
@action_provider.preprocess(@site)
|
21
|
-
|
22
|
-
@dependency_store.items = @site.items
|
23
|
-
@dependency_store.layouts = @site.layouts
|
24
|
-
@checksum_store.objects = @site.items.to_a + @site.layouts.to_a + @site.code_snippets + [@site.config]
|
25
|
-
end
|
26
|
-
|
27
|
-
@site.mark_as_preprocessed
|
28
|
-
@site.freeze
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class Prune < Nanoc::Core::CompilationStage
|
8
|
-
def initialize(config:, reps:)
|
9
|
-
@config = config
|
10
|
-
@reps = reps
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
if @config[:prune][:auto_prune]
|
15
|
-
Nanoc::Pruner.new(@config, @reps, exclude: prune_config_exclude).run
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def prune_config
|
22
|
-
@config[:prune] || {}
|
23
|
-
end
|
24
|
-
|
25
|
-
def prune_config_exclude
|
26
|
-
prune_config[:exclude] || {}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class StorePostCompilationState < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(dependency_store:)
|
11
|
-
@dependency_store = dependency_store
|
12
|
-
end
|
13
|
-
|
14
|
-
contract C::None => C::Any
|
15
|
-
def run
|
16
|
-
@dependency_store.store
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Compiler
|
6
|
-
module Stages
|
7
|
-
class StorePreCompilationState < Nanoc::Core::CompilationStage
|
8
|
-
include Nanoc::Core::ContractsSupport
|
9
|
-
|
10
|
-
def initialize(reps:, layouts:, checksum_store:, action_sequence_store:, action_sequences:)
|
11
|
-
@reps = reps
|
12
|
-
@layouts = layouts
|
13
|
-
@checksum_store = checksum_store
|
14
|
-
@action_sequence_store = action_sequence_store
|
15
|
-
@action_sequences = action_sequences
|
16
|
-
end
|
17
|
-
|
18
|
-
contract Nanoc::Core::ChecksumCollection => C::Any
|
19
|
-
def run(checksums)
|
20
|
-
# Calculate action sequence
|
21
|
-
(@reps.to_a + @layouts.to_a).each do |obj|
|
22
|
-
@action_sequence_store[obj] = @action_sequences[obj].serialize
|
23
|
-
end
|
24
|
-
@action_sequence_store.store
|
25
|
-
|
26
|
-
# Set checksums
|
27
|
-
@checksum_store.checksums = checksums.to_h
|
28
|
-
@checksum_store.store
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
# @api private
|
6
|
-
class CompilerLoader
|
7
|
-
def load(site, action_provider: nil)
|
8
|
-
action_sequence_store = Nanoc::Core::ActionSequenceStore.new(config: site.config)
|
9
|
-
|
10
|
-
dependency_store =
|
11
|
-
Nanoc::Core::DependencyStore.new(site.items, site.layouts, site.config)
|
12
|
-
|
13
|
-
objects = site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]
|
14
|
-
|
15
|
-
checksum_store =
|
16
|
-
Nanoc::Core::ChecksumStore.new(config: site.config, objects: objects)
|
17
|
-
|
18
|
-
action_provider ||= Nanoc::Core::ActionProvider.named(site.config.action_provider).for(site)
|
19
|
-
|
20
|
-
outdatedness_store =
|
21
|
-
Nanoc::Core::OutdatednessStore.new(config: site.config)
|
22
|
-
|
23
|
-
compiled_content_cache =
|
24
|
-
compiled_content_cache_class.new(config: site.config)
|
25
|
-
|
26
|
-
params = {
|
27
|
-
compiled_content_cache: compiled_content_cache,
|
28
|
-
checksum_store: checksum_store,
|
29
|
-
action_sequence_store: action_sequence_store,
|
30
|
-
dependency_store: dependency_store,
|
31
|
-
action_provider: action_provider,
|
32
|
-
outdatedness_store: outdatedness_store,
|
33
|
-
}
|
34
|
-
|
35
|
-
Nanoc::Int::Compiler.new(site, params)
|
36
|
-
end
|
37
|
-
|
38
|
-
def compiled_content_cache_class
|
39
|
-
feature_name = Nanoc::Feature::BINARY_COMPILED_CONTENT_CACHE
|
40
|
-
if Nanoc::Feature.enabled?(feature_name)
|
41
|
-
Nanoc::Core::CompiledContentCache
|
42
|
-
else
|
43
|
-
Nanoc::Core::TextualCompiledContentCache
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class Executor
|
6
|
-
def initialize(rep, compilation_context, dependency_tracker)
|
7
|
-
@rep = rep
|
8
|
-
@compilation_context = compilation_context
|
9
|
-
@dependency_tracker = dependency_tracker
|
10
|
-
end
|
11
|
-
|
12
|
-
def filter(filter_name, filter_args = {})
|
13
|
-
filter = filter_for_filtering(filter_name)
|
14
|
-
|
15
|
-
begin
|
16
|
-
Nanoc::Core::NotificationCenter.post(:filtering_started, @rep, filter_name)
|
17
|
-
|
18
|
-
# Run filter
|
19
|
-
last = @compilation_context.compiled_content_store.get_current(@rep)
|
20
|
-
source = last.binary? ? last.filename : last.string
|
21
|
-
filter_args.freeze
|
22
|
-
result = filter.setup_and_run(source, filter_args)
|
23
|
-
last =
|
24
|
-
if filter.class.to_binary?
|
25
|
-
Nanoc::Core::BinaryContent.new(filter.output_filename).tap(&:freeze)
|
26
|
-
else
|
27
|
-
Nanoc::Core::TextualContent.new(result).tap(&:freeze)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Store
|
31
|
-
@compilation_context.compiled_content_store.set_current(@rep, last)
|
32
|
-
ensure
|
33
|
-
Nanoc::Core::NotificationCenter.post(:filtering_ended, @rep, filter_name)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def layout(layout_identifier, extra_filter_args = nil)
|
38
|
-
layout = find_layout(layout_identifier)
|
39
|
-
filter_name_and_args = @compilation_context.filter_name_and_args_for_layout(layout)
|
40
|
-
filter_name = filter_name_and_args.name
|
41
|
-
if filter_name.nil?
|
42
|
-
raise ::Nanoc::Core::Error, "Cannot find rule for layout matching #{layout_identifier}"
|
43
|
-
end
|
44
|
-
|
45
|
-
filter_args = filter_name_and_args.args
|
46
|
-
filter_args = filter_args.merge(extra_filter_args || {})
|
47
|
-
filter_args.freeze
|
48
|
-
|
49
|
-
# Check whether item can be laid out
|
50
|
-
last = @compilation_context.compiled_content_store.get_current(@rep)
|
51
|
-
raise Nanoc::Int::Errors::CannotLayoutBinaryItem.new(@rep) if last.binary?
|
52
|
-
|
53
|
-
# Create filter
|
54
|
-
klass = Nanoc::Filter.named!(filter_name)
|
55
|
-
layout_view = Nanoc::LayoutView.new(layout, view_context)
|
56
|
-
filter = klass.new(assigns.merge(layout: layout_view))
|
57
|
-
|
58
|
-
# Visit
|
59
|
-
@dependency_tracker.bounce(layout, raw_content: true)
|
60
|
-
|
61
|
-
begin
|
62
|
-
Nanoc::Core::NotificationCenter.post(:filtering_started, @rep, filter_name)
|
63
|
-
|
64
|
-
# Layout
|
65
|
-
content = layout.content
|
66
|
-
arg = content.binary? ? content.filename : content.string
|
67
|
-
res = filter.setup_and_run(arg, filter_args)
|
68
|
-
|
69
|
-
# Store
|
70
|
-
last = Nanoc::Core::TextualContent.new(res).tap(&:freeze)
|
71
|
-
@compilation_context.compiled_content_store.set_current(@rep, last)
|
72
|
-
ensure
|
73
|
-
Nanoc::Core::NotificationCenter.post(:filtering_ended, @rep, filter_name)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def snapshot(snapshot_name)
|
78
|
-
last = @compilation_context.compiled_content_store.get_current(@rep)
|
79
|
-
@compilation_context.compiled_content_store.set(@rep, snapshot_name, last)
|
80
|
-
Nanoc::Core::NotificationCenter.post(:snapshot_created, @rep, snapshot_name)
|
81
|
-
end
|
82
|
-
|
83
|
-
def assigns
|
84
|
-
view_context.assigns_for(@rep, site: @compilation_context.site)
|
85
|
-
end
|
86
|
-
|
87
|
-
def layouts
|
88
|
-
@compilation_context.site.layouts
|
89
|
-
end
|
90
|
-
|
91
|
-
def find_layout(arg)
|
92
|
-
req_id = arg.__nanoc_cleaned_identifier
|
93
|
-
layout = layouts[req_id]
|
94
|
-
return layout if layout
|
95
|
-
|
96
|
-
if use_globs?
|
97
|
-
pat = Nanoc::Core::Pattern.from(arg)
|
98
|
-
layout = layouts.find { |l| pat.match?(l.identifier) }
|
99
|
-
return layout if layout
|
100
|
-
end
|
101
|
-
|
102
|
-
raise Nanoc::Int::Errors::UnknownLayout.new(arg)
|
103
|
-
end
|
104
|
-
|
105
|
-
def filter_for_filtering(filter_name)
|
106
|
-
klass = Nanoc::Filter.named!(filter_name)
|
107
|
-
|
108
|
-
last = @compilation_context.compiled_content_store.get_current(@rep)
|
109
|
-
if klass.from_binary? && !last.binary?
|
110
|
-
raise Nanoc::Int::Errors::CannotUseBinaryFilter.new(@rep, klass)
|
111
|
-
elsif !klass.from_binary? && last.binary?
|
112
|
-
raise Nanoc::Int::Errors::CannotUseTextualFilter.new(@rep, klass)
|
113
|
-
end
|
114
|
-
|
115
|
-
klass.new(assigns)
|
116
|
-
end
|
117
|
-
|
118
|
-
def use_globs?
|
119
|
-
@compilation_context.site.config[:string_pattern_type] == 'glob'
|
120
|
-
end
|
121
|
-
|
122
|
-
def view_context
|
123
|
-
@_view_context ||=
|
124
|
-
Nanoc::Core::ViewContextForCompilation.new(
|
125
|
-
reps: @compilation_context.reps,
|
126
|
-
items: @compilation_context.site.items,
|
127
|
-
dependency_tracker: @dependency_tracker,
|
128
|
-
compilation_context: @compilation_context,
|
129
|
-
compiled_content_store: @compilation_context.compiled_content_store,
|
130
|
-
)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|