muwu 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/muwu +5 -0
- data/lib/muwu.rb +38 -0
- data/lib/muwu/cli/cli.rb +143 -0
- data/lib/muwu/cli/cli_help.rb +28 -0
- data/lib/muwu/cli/help/compile +22 -0
- data/lib/muwu/cli/help/concat +8 -0
- data/lib/muwu/cli/help/heading +2 -0
- data/lib/muwu/cli/help/inspect +7 -0
- data/lib/muwu/cli/help/new +8 -0
- data/lib/muwu/cli/help/reset +14 -0
- data/lib/muwu/cli/help/summary +14 -0
- data/lib/muwu/controller/controller.rb +120 -0
- data/lib/muwu/controller/controller_interaction.rb +146 -0
- data/lib/muwu/default/default.rb +51 -0
- data/lib/muwu/destination/destination.rb +212 -0
- data/lib/muwu/destination_builder/destination_builder.rb +127 -0
- data/lib/muwu/helper/hash_helper.rb +37 -0
- data/lib/muwu/helper/html_href_helper.rb +101 -0
- data/lib/muwu/helper/outline_helper.rb +160 -0
- data/lib/muwu/helper/regexp_lib.rb +101 -0
- data/lib/muwu/helper/sanitizer_helper.rb +50 -0
- data/lib/muwu/manifest/manifest.rb +158 -0
- data/lib/muwu/manifest_builder/manifest_builder.rb +102 -0
- data/lib/muwu/manifest_task/contents.rb +42 -0
- data/lib/muwu/manifest_task/document_css.rb +25 -0
- data/lib/muwu/manifest_task/document_html.rb +69 -0
- data/lib/muwu/manifest_task/document_js.rb +25 -0
- data/lib/muwu/manifest_task/metadata.rb +35 -0
- data/lib/muwu/manifest_task/navigator.rb +29 -0
- data/lib/muwu/manifest_task/subcontents.rb +48 -0
- data/lib/muwu/manifest_task/text.rb +51 -0
- data/lib/muwu/manifest_task/text_item.rb +124 -0
- data/lib/muwu/manifest_task/title.rb +34 -0
- data/lib/muwu/manifest_task_builder/contents_builder.rb +88 -0
- data/lib/muwu/manifest_task_builder/document_css_builder.rb +63 -0
- data/lib/muwu/manifest_task_builder/document_html_builder.rb +210 -0
- data/lib/muwu/manifest_task_builder/document_js_builder.rb +69 -0
- data/lib/muwu/manifest_task_builder/metadata_builder.rb +118 -0
- data/lib/muwu/manifest_task_builder/navigator_builder.rb +78 -0
- data/lib/muwu/manifest_task_builder/subcontents_builder.rb +90 -0
- data/lib/muwu/manifest_task_builder/text_builder.rb +125 -0
- data/lib/muwu/manifest_task_builder/text_item_builder.rb +314 -0
- data/lib/muwu/manifest_task_builder/title_builder.rb +122 -0
- data/lib/muwu/project/project.rb +430 -0
- data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +138 -0
- data/lib/muwu/project_builder/assets/config/css/base/index.scss +11 -0
- data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +23 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +58 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +17 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +13 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +58 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +48 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +22 -0
- data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +32 -0
- data/lib/muwu/project_builder/assets/config/css/colors/index.scss +1 -0
- data/lib/muwu/project_builder/assets/config/css/colors/light.scss +34 -0
- data/lib/muwu/project_builder/assets/config/css/extensions/index.scss +1 -0
- data/lib/muwu/project_builder/assets/config/css/index.scss +19 -0
- data/lib/muwu/project_builder/assets/config/css_debugger/debug_section_text.scss +27 -0
- data/lib/muwu/project_builder/project_reader.rb +144 -0
- data/lib/muwu/project_builder/project_reset_css.rb +95 -0
- data/lib/muwu/project_builder/project_starter.rb +27 -0
- data/lib/muwu/project_builder/project_validator.rb +157 -0
- data/lib/muwu/project_builder/project_writer.rb +127 -0
- data/lib/muwu/project_exception/css_manifest_file_not_found.rb +23 -0
- data/lib/muwu/project_exception/dry_output_recommended_with_multiple_documents.rb +19 -0
- data/lib/muwu/project_exception/metadata_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/metadata_value_not_given.rb +42 -0
- data/lib/muwu/project_exception/multiple_documents_outlined_with_stdout.rb +18 -0
- data/lib/muwu/project_exception/multiple_formats_requested_with_stdout.rb +18 -0
- data/lib/muwu/project_exception/navigator_not_recommended_with_stdout.rb +23 -0
- data/lib/muwu/project_exception/navigators_will_be_generated_automatically.rb +23 -0
- data/lib/muwu/project_exception/option_key_not_understood.rb +23 -0
- data/lib/muwu/project_exception/option_not_validatable.rb +23 -0
- data/lib/muwu/project_exception/option_value_not_understood.rb +24 -0
- data/lib/muwu/project_exception/options_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/outline_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/outline_step_not_understood.rb +23 -0
- data/lib/muwu/project_exception/output_already_open.rb +18 -0
- data/lib/muwu/project_exception/output_not_open.rb +18 -0
- data/lib/muwu/project_exception/subcontents_will_be_generated_automatically copy.rb +23 -0
- data/lib/muwu/project_exception/target_project_folder_already_exists.rb +24 -0
- data/lib/muwu/project_exception/text_source_file_not_found.rb +26 -0
- data/lib/muwu/project_exception_handler/fatal.rb +39 -0
- data/lib/muwu/project_options/project_options.rb +54 -0
- data/lib/muwu/project_options_builder/project_option_validator.rb +37 -0
- data/lib/muwu/project_options_builder/project_option_validator_key.rb +56 -0
- data/lib/muwu/project_options_builder/project_option_validator_value.rb +300 -0
- data/lib/muwu/project_options_builder/project_options_reader.rb +80 -0
- data/lib/muwu/render_concat/render_concat.rb +80 -0
- data/lib/muwu/render_html/render_html.rb +101 -0
- data/lib/muwu/render_html/render_markup_to_html.rb +87 -0
- data/lib/muwu/render_html_builder/render_css_builder.rb +34 -0
- data/lib/muwu/render_html_builder/render_html_builder.rb +34 -0
- data/lib/muwu/render_html_builder/render_js_builder.rb +34 -0
- data/lib/muwu/render_html_partial/js_library/_init_bare.js +7 -0
- data/lib/muwu/render_html_partial/js_library/_zepto.min.js +2 -0
- data/lib/muwu/render_html_partial/js_library/init.js +10 -0
- data/lib/muwu/render_html_partial/js_library/navigation.js +140 -0
- data/lib/muwu/render_html_partial/render_contents.rb +369 -0
- data/lib/muwu/render_html_partial/render_document_css.rb +45 -0
- data/lib/muwu/render_html_partial/render_document_html.rb +397 -0
- data/lib/muwu/render_html_partial/render_document_js.rb +37 -0
- data/lib/muwu/render_html_partial/render_js_library.rb +54 -0
- data/lib/muwu/render_html_partial/render_metadata.rb +120 -0
- data/lib/muwu/render_html_partial/render_navigator.rb +136 -0
- data/lib/muwu/render_html_partial/render_subcontents.rb +374 -0
- data/lib/muwu/render_html_partial/render_text.rb +74 -0
- data/lib/muwu/render_html_partial/render_text_item.rb +230 -0
- data/lib/muwu/render_html_partial/render_title.rb +71 -0
- data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +100 -0
- data/lib/muwu/render_html_partial_builder/render_document_css_builder.rb +46 -0
- data/lib/muwu/render_html_partial_builder/render_document_html_builder.rb +211 -0
- data/lib/muwu/render_html_partial_builder/render_document_js_builder.rb +52 -0
- data/lib/muwu/render_html_partial_builder/render_metadata_builder.rb +47 -0
- data/lib/muwu/render_html_partial_builder/render_navigator_builder.rb +74 -0
- data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +85 -0
- data/lib/muwu/render_html_partial_builder/render_text_builder.rb +86 -0
- data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +274 -0
- data/lib/muwu/render_html_partial_builder/render_title_builder.rb +47 -0
- data/lib/muwu/render_inspector/render_inspector.rb +224 -0
- data/lib/muwu/var/deflistdiv.rb +239 -0
- data/lib/muwu_loader.rb +35 -0
- data/test/what_no_tests.md +5 -0
- metadata +251 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dafa3354f3a57677adacf16fe9372167ce2572b68e445fb0f95192142c116633
|
4
|
+
data.tar.gz: 83130270c6bcfbbb7c3fd46a3cc8825441999eae801dd1ba15368acffc315464
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a036a78dd8a1ef10f0776a7d014c4e953ababeb0ca154e0718499a8252b06b3b4a708fa9c4542803a986e70f0fdad4bef8e9997b541eabb9f01858f82118722
|
7
|
+
data.tar.gz: 819c5595a937ff67464e3829b0243d86a2cf3b429bcadf232dfc13eea7995d9c6fe583c48f39555479597a66ebc4cff2dc95eb199693ffd10dcb3d9850a281df
|
data/bin/muwu
ADDED
data/lib/muwu.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Muwu
|
2
|
+
|
3
|
+
|
4
|
+
VERSION = '2.5.1'
|
5
|
+
|
6
|
+
GEM_HOME_LIB = File.absolute_path(File.join(File.dirname(__FILE__)))
|
7
|
+
GEM_HOME_LIB_MUWU = File.absolute_path(File.join(GEM_HOME_LIB, 'muwu'))
|
8
|
+
|
9
|
+
|
10
|
+
require 'commonmarker'
|
11
|
+
require 'fileutils'
|
12
|
+
require 'haml'
|
13
|
+
require 'iso-639'
|
14
|
+
require 'logger'
|
15
|
+
require 'motion-markdown-it'
|
16
|
+
require 'motion-markdown-it-plugins'
|
17
|
+
require 'sassc'
|
18
|
+
require 'yaml'
|
19
|
+
|
20
|
+
|
21
|
+
require_relative 'muwu_loader'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
module_function
|
26
|
+
|
27
|
+
|
28
|
+
def debug(file, line, info)
|
29
|
+
logger.new(STDERR).debug("#{file} #{line} #{info}")
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def read(path)
|
34
|
+
ProjectReader.build { |b| b.load_path(path) }
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
data/lib/muwu/cli/cli.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
module Muwu
|
2
|
+
class Cli
|
3
|
+
|
4
|
+
|
5
|
+
include Muwu
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(args)
|
9
|
+
@args = args.map do |a|
|
10
|
+
case a
|
11
|
+
when nil
|
12
|
+
nil
|
13
|
+
else
|
14
|
+
a.downcase.strip
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
@current_working_directory = Dir.pwd
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
public
|
24
|
+
|
25
|
+
|
26
|
+
def evaluate_arguments
|
27
|
+
if @args == []
|
28
|
+
puts CliHelp.new(:summary).message
|
29
|
+
elsif @args != []
|
30
|
+
case @args[0]
|
31
|
+
when 'compile'
|
32
|
+
evaluate_command_compile
|
33
|
+
when 'concat'
|
34
|
+
evaluate_command_concat
|
35
|
+
when 'help'
|
36
|
+
evaluate_command_help
|
37
|
+
when 'inspect'
|
38
|
+
evaluate_command_inspect
|
39
|
+
when 'new'
|
40
|
+
evaluate_command_new
|
41
|
+
when 'reset'
|
42
|
+
evaluate_command_reset
|
43
|
+
when '--version'
|
44
|
+
puts VERSION
|
45
|
+
else
|
46
|
+
puts CliHelp.new(:summary).message
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
|
56
|
+
def evaluate_command_compile
|
57
|
+
if @args[1] == nil
|
58
|
+
Controller.new(@current_working_directory).compile
|
59
|
+
|
60
|
+
elsif @args[1] == 'css'
|
61
|
+
Controller.new(@current_working_directory).compile_css
|
62
|
+
|
63
|
+
elsif @args[1] == 'html'
|
64
|
+
evaluate_command_compile_html
|
65
|
+
|
66
|
+
elsif @args[1] == 'js'
|
67
|
+
Controller.new(@current_working_directory).compile_js
|
68
|
+
|
69
|
+
else
|
70
|
+
puts CliHelp.new(:compile).message
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def evaluate_command_compile_html
|
76
|
+
if @args[2] == nil
|
77
|
+
Controller.new(@current_working_directory).compile_html
|
78
|
+
|
79
|
+
elsif @args[2] =~ /\A[0-9]+\z/
|
80
|
+
Controller.new(@current_working_directory).compile_html_by_index(@args[2].to_i)
|
81
|
+
|
82
|
+
else
|
83
|
+
puts CliHelp.new(:compile).message
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def evaluate_command_concat
|
89
|
+
Controller.new(@current_working_directory).concat
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
def evaluate_command_help
|
95
|
+
if @args[1] == nil
|
96
|
+
puts CliHelp.new(:summary).message
|
97
|
+
|
98
|
+
else
|
99
|
+
case @args[1]
|
100
|
+
when 'compile'
|
101
|
+
puts CliHelp.new(:compile).message
|
102
|
+
when 'concat'
|
103
|
+
puts CliHelp.new(:concat).message
|
104
|
+
when 'inspect'
|
105
|
+
puts CliHelp.new(:inspect).message
|
106
|
+
when 'new'
|
107
|
+
puts CliHelp.new(:new).message
|
108
|
+
when 'reset'
|
109
|
+
puts CliHelp.new(:reset).message
|
110
|
+
else
|
111
|
+
puts CliHelp.new(:summary).message
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
def evaluate_command_inspect
|
118
|
+
Controller.new(@current_working_directory).inspect
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def evaluate_command_new
|
123
|
+
Controller.new(@current_working_directory).new_project
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
def evaluate_command_reset
|
128
|
+
if @args[1] == nil
|
129
|
+
puts CliHelp.new(:reset).message
|
130
|
+
|
131
|
+
else
|
132
|
+
case @args[1]
|
133
|
+
when 'css'
|
134
|
+
Controller.new(@current_working_directory).reset_css
|
135
|
+
else
|
136
|
+
puts CliHelp.new(:reset).message
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Muwu
|
2
|
+
class CliHelp
|
3
|
+
|
4
|
+
|
5
|
+
def initialize(message)
|
6
|
+
@heading = File.open(File.join(GEM_HOME_LIB_MUWU,'cli/help/heading')).read.strip
|
7
|
+
@version = "#{version_statement}\n"
|
8
|
+
@message = File.open(File.join(GEM_HOME_LIB_MUWU,'cli/help',message.to_s.downcase)).read.strip
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def message
|
13
|
+
[@heading, @version, @message].join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
|
21
|
+
def version_statement
|
22
|
+
"\# version #{VERSION}"
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
- muwu compile
|
2
|
+
- Compile all parts of the the project located in the current working
|
3
|
+
directory.
|
4
|
+
|
5
|
+
- muwu compile css
|
6
|
+
- Compile only the stylesheet for the project.
|
7
|
+
|
8
|
+
- muwu compile html
|
9
|
+
- Compile only the html file(s) for the project.
|
10
|
+
|
11
|
+
- muwu compile html [index]
|
12
|
+
- Compile only a single outlined content document, indicated by
|
13
|
+
[index]. Use the command `muwu inspect` to determine the index
|
14
|
+
number of a document.
|
15
|
+
|
16
|
+
- muwu compile js
|
17
|
+
- Compile only the javascript library (if applicable) for the project.
|
18
|
+
|
19
|
+
* Compiling a project will overwrite any previous output files without
|
20
|
+
any warning.
|
21
|
+
|
22
|
+
* You can specify output filenames in `options.yml`.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
- muwu inspect
|
2
|
+
- Inspect the project in the current working directory, and show details
|
3
|
+
about the project, the project outline, and the project manifest (the list
|
4
|
+
of documents that would be produced by the command `muwu compile`.)
|
5
|
+
|
6
|
+
* Inspecting a project does not create or overwrite any files.
|
7
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- muwu new
|
2
|
+
- Create a new project as a subdirectory from the current working directory.
|
3
|
+
Muwu will ask for a directory name. If the directory does not exist, Muwu
|
4
|
+
will create it and fill it with a blank new project.
|
5
|
+
|
6
|
+
* Only alphanumeric (a-z, A-Z, 0-9) and underscore (_) characters are allowed
|
7
|
+
in the directory name.
|
8
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- reset css
|
2
|
+
- Reset the `config/css` folder. The following files and folders will
|
3
|
+
revert to their original state:
|
4
|
+
|
5
|
+
- config/css/base/
|
6
|
+
- config/css/colors/dark.scss
|
7
|
+
- config/css/colors/index.scss
|
8
|
+
- config/css/colors/light.scss
|
9
|
+
- config/css/index.scss
|
10
|
+
|
11
|
+
* If `config/css/extensions` does exist, it and its contents will remain
|
12
|
+
unchanged.
|
13
|
+
|
14
|
+
* If `config/css/extensions` does not exist, Muwu will create it.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"muwu – Because sometimes WYSIWYG is not WYW."
|
2
|
+
|
3
|
+
Command line:
|
4
|
+
muwu compile compile a project into an HTML document suite
|
5
|
+
muwu concat combine all source text into a single .md file
|
6
|
+
muwu help show this message
|
7
|
+
muwu inspect inspect a project
|
8
|
+
muwu new create a new project directory
|
9
|
+
muwu reset css reset the default CSS files
|
10
|
+
|
11
|
+
All comands operate within the current working directory.
|
12
|
+
|
13
|
+
For more detailed instructions:
|
14
|
+
muwu help [command]
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Muwu
|
2
|
+
class Controller
|
3
|
+
|
4
|
+
|
5
|
+
include Muwu
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(current_working_directory)
|
9
|
+
@current_working_directory = File.absolute_path(current_working_directory)
|
10
|
+
@project = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
|
18
|
+
def compile
|
19
|
+
@project = read_project_from_current_working_directory
|
20
|
+
if @project.does_not_have_crucial_files
|
21
|
+
reply_folder_does_not_have_valid_project
|
22
|
+
else
|
23
|
+
RenderHtml.new(@project).render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def compile_css
|
29
|
+
@project = read_project_from_current_working_directory
|
30
|
+
if @project.does_not_have_crucial_files
|
31
|
+
reply_folder_does_not_have_valid_project
|
32
|
+
else
|
33
|
+
RenderHtml.new(@project).render_css_only
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def compile_html_by_index(index)
|
39
|
+
@project = read_project_from_current_working_directory
|
40
|
+
if @project.does_not_have_crucial_files
|
41
|
+
reply_folder_does_not_have_valid_project
|
42
|
+
else
|
43
|
+
RenderHtml.new(@project).render_html_by_index(index)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def compile_html
|
49
|
+
@project = read_project_from_current_working_directory
|
50
|
+
if @project.does_not_have_crucial_files
|
51
|
+
reply_folder_does_not_have_valid_project
|
52
|
+
else
|
53
|
+
RenderHtml.new(@project).render_html_only
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def compile_js
|
59
|
+
@project = read_project_from_current_working_directory
|
60
|
+
if @project.does_not_have_crucial_files
|
61
|
+
reply_folder_does_not_have_valid_project
|
62
|
+
else
|
63
|
+
RenderHtml.new(@project).render_js_only
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def concat
|
69
|
+
@project = read_project_from_current_working_directory
|
70
|
+
if @project.does_not_have_crucial_files
|
71
|
+
reply_folder_does_not_have_valid_project
|
72
|
+
else
|
73
|
+
RenderConcat.new(@project).render
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def inspect
|
79
|
+
@project = read_project_from_current_working_directory
|
80
|
+
if @project.does_not_have_crucial_files
|
81
|
+
reply_folder_does_not_have_valid_project
|
82
|
+
else
|
83
|
+
RenderInspector.new(@project).render_inspector
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def new_project
|
89
|
+
metadata = ControllerInteraction.new.request_metadata
|
90
|
+
@project = ProjectStarter.new(@current_working_directory, metadata).new_project
|
91
|
+
ProjectWriter.new(@project).write
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def reset_css
|
96
|
+
@project = read_project_from_current_working_directory
|
97
|
+
if @project.does_not_have_crucial_files
|
98
|
+
reply_folder_does_not_have_valid_project
|
99
|
+
elsif ControllerInteraction.new.confirm_reset_css(@project)
|
100
|
+
ProjectResetCss.new(@project).reset_css
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
|
109
|
+
def read_project_from_current_working_directory
|
110
|
+
ProjectReader.build { |b| b.load_path(@current_working_directory) }
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def reply_folder_does_not_have_valid_project
|
115
|
+
puts @project.exceptions
|
116
|
+
puts "Is this a Muwu project folder?"
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Muwu
|
2
|
+
class ControllerInteraction
|
3
|
+
|
4
|
+
|
5
|
+
attr_accessor :slug
|
6
|
+
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@slug = ''
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
public
|
15
|
+
|
16
|
+
|
17
|
+
def confirm_reset_css(project)
|
18
|
+
render_reset_css_heading(project)
|
19
|
+
render_reset_css_prompt
|
20
|
+
@answer = $stdin.gets.chomp.strip.downcase
|
21
|
+
if @answer == 'y'
|
22
|
+
return true
|
23
|
+
else
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def request_metadata
|
30
|
+
request_metadata_phase_1_render_heading
|
31
|
+
request_metadata_phase_2_request_and_set_slug
|
32
|
+
{ slug: @slug }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def request_metadata_phase_1_render_heading
|
37
|
+
render_new_project_heading
|
38
|
+
render_lf
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def request_metadata_phase_2_request_and_set_slug
|
43
|
+
render_slug_heading
|
44
|
+
while @slug == ''
|
45
|
+
render_slug_can_not_be_blank
|
46
|
+
render_slug_prompt
|
47
|
+
@slug = $stdin.gets.chomp.strip
|
48
|
+
if @slug.match(/\W/)
|
49
|
+
@slug.gsub!(/\W/,'')
|
50
|
+
render_slug_was_sanitized(result: @slug)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
render_lf
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
def determine_reset_css_files(project)
|
63
|
+
[
|
64
|
+
File.join(project.path_css_base),
|
65
|
+
File.join(project.path_css_colors, 'dark.scss'),
|
66
|
+
File.join(project.path_css_colors, 'index.scss'),
|
67
|
+
File.join(project.path_css_colors, 'light.scss'),
|
68
|
+
File.join(project.path_css, 'index.scss'),
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def render_lf
|
74
|
+
puts "\n"
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def render_new_project_heading
|
79
|
+
puts '# Muwu'
|
80
|
+
puts '# New Project'
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def render_reset_css_heading(project)
|
85
|
+
puts '# Muwu'
|
86
|
+
puts '# Reset CSS'
|
87
|
+
puts
|
88
|
+
puts '- This will reset the following files and folders to their original state:'
|
89
|
+
puts
|
90
|
+
determine_reset_css_files(project).each do |file|
|
91
|
+
puts " - #{file}"
|
92
|
+
end
|
93
|
+
puts
|
94
|
+
puts "* If #{project.path_css_extensions} does not exist, it will be created."
|
95
|
+
puts ' Otherwise, its existing contents will remain unchanged.'
|
96
|
+
puts
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def render_reset_css_prompt
|
101
|
+
print '> Continue with CSS reset? (y/N) '
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def render_slug_heading
|
106
|
+
puts '# Project Directory Name'
|
107
|
+
puts '- Word characters `[a-zA-Z0-9_]` only; non-word characters will be removed.'
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def render_slug_prompt
|
112
|
+
print '> Directory Name for project: '
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def render_slug_can_not_be_blank
|
117
|
+
puts '- Directory Name can not be blank.'
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
def render_slug_was_sanitized(result: nil)
|
122
|
+
puts '- Directory Name contained non-word characters that were removed.'
|
123
|
+
if result
|
124
|
+
puts " - Modified Directory Name: `#{result}`"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def render_title_heading
|
130
|
+
puts "\n"
|
131
|
+
puts '# Project Title'
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
def render_title_prompt
|
136
|
+
print '> Title of project: '
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
def render_title_can_not_be_blank
|
141
|
+
puts '- Title can not be blank.'
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|