Class: Scriptorium::StandardFiles
- Inherits:
-
Object
- Object
- Scriptorium::StandardFiles
show all
- Includes:
- Helpers
- Defined in:
- lib/scriptorium/standard_files.rb
Instance Method Summary
collapse
-
#available_widgets ⇒ Object
-
#common_js ⇒ Object
-
#deploy_text ⇒ Object
-
#highlight_ruby_js ⇒ Object
-
#html_head_content(view = nil) ⇒ Object
-
#initial_post(mode = :filled, num: "0", title: nil, blurb: nil, views: nil, tags: nil, body: nil) ⇒ Object
-
#initial_post_metadata(num: "0", title: nil, blurb: nil, views: nil, tags: nil) ⇒ Object
-
#initialize ⇒ StandardFiles
constructor
-
#post_template ⇒ Object
-
#status_txt ⇒ Object
-
#support_data(relative_path) ⇒ Object
-
#svg_txt ⇒ Object
Methods included from Helpers
#add_post_to_state_file, #cf_time, #change_config, #clean_slugify, #copy_gem_asset_to_user, #copy_to_clipboard, #d4, #escape_html, #find_asset, #format_date, #generate_missing_asset_svg, #get_asset_path, #get_from_clipboard, #getvars, #list_gem_assets, #make_dir, #make_tree, #need, #parse_commented_file, #post_compare, #post_in_state_file?, #read_commented_file, #read_file, #read_post_state_file, #remove_post_from_state_file, #see, #see_file, #slugify, #substitute, #system!, #tty, #view_dir, #write_file, #write_file!, #write_post_state_file, #ymdhms, #ymdhms_filename
Methods included from Exceptions
#make_exception
Constructor Details
7
8
|
# File 'lib/scriptorium/standard_files.rb', line 7
def initialize end
|
Instance Method Details
49
50
51
52
53
54
55
|
# File 'lib/scriptorium/standard_files.rb', line 49
def available_widgets
<<~EOS
links
pages
featuredposts
EOS
end
|
#common_js ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/scriptorium/standard_files.rb', line 30
def common_js
files = [
'common_js/navigation.js',
'common_js/content-loader.js',
'common_js/syntax-highlighting.js',
'common_js/clipboard.js'
]
files.map { |file| support_data(file) }.join("\n\n")
end
|
#deploy_text ⇒ Object
128
129
130
131
132
133
134
135
136
|
# File 'lib/scriptorium/standard_files.rb', line 128
def deploy_text
<<~EOS
user root
server %{domain}
docroot /var/www/html
path %{view}
proto https
EOS
end
|
#highlight_ruby_js ⇒ Object
43
44
45
46
47
|
# File 'lib/scriptorium/standard_files.rb', line 43
def highlight_ruby_js
<<~EOS
src https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/ruby.min.js
EOS
end
|
#html_head_content(view = nil) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/scriptorium/standard_files.rb', line 10
def html_head_content(view = nil)
line1global = "# This global file supplies the default values for all views."
line2view = "# This view-specific file supplies the default values for this view."
line1 = view ? line2view : line1global
str = <<~EOS
#{line1}
# title is omitted - filled in at generation
charset UTF-8
desc A blog powered by Scriptorium. This is default text intended to be changed by the user.
viewport width=device-width initial-scale=1.0
robots index follow
javascript # See common.js
bootstrap # See bootstrap.txt
social # See social.txt for configuration
highlight # See highlight_css.txt for syntax highlighting
highlight_custom # Custom CSS overrides for Highlight.js
EOS
str
end
|
#initial_post(mode = :filled, num: "0", title: nil, blurb: nil, views: nil, tags: nil, body: nil) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/scriptorium/standard_files.rb', line 58
def initial_post(mode = :filled, num: "0", title: nil, blurb: nil, views: nil,
tags: nil, body: nil)
title ||= "ADD TITLE HERE"
blurb ||= "ADD BLURB HERE"
views ||= %w[sample]
tags ||= %w[sample tags]
body ||= "BEGIN HERE..."
str = support_data('templates/initial_post.lt3')
return str if mode == :raw
mytags = tags
mytags = tags.join(", ") if tags.is_a?(Array)
str2 = str % {num: d4(num.to_i), created: ymdhms, title: title, blurb: blurb,
views: views.join(" "), tags: mytags, body: body}
return str2
end
|
#initial_post_metadata(num: "0", title: nil, blurb: nil, views: nil, tags: nil) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/scriptorium/standard_files.rb', line 77
def initial_post_metadata(num: "0", title: nil, blurb: nil, views: nil, tags: nil)
title ||= "ADD TITLE HERE"
blurb ||= "ADD BLURB HERE"
views ||= %w[sample]
tags ||= %w[sample tags]
mytags = tags
mytags = tags.join(", ") if tags.is_a?(Array)
<<~EOS
post.id #{d4(num.to_i)}
post.created #{ymdhms}
post.published no
post.deployed no
post.title #{title}
post.blurb #{blurb}
post.views #{views.join(" ")}
post.tags #{mytags}
EOS
end
|
#post_template ⇒ Object
102
103
104
|
# File 'lib/scriptorium/standard_files.rb', line 102
def post_template
support_data('templates/post.lt3')
end
|
#status_txt ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/scriptorium/standard_files.rb', line 138
def status_txt
<<~EOS
header n
banner n
navbar n
left n
right n
pages n
deploy n
EOS
end
|
#support_data(relative_path) ⇒ Object
98
99
100
|
# File 'lib/scriptorium/standard_files.rb', line 98
def support_data(relative_path)
read_file(support_file(relative_path))
end
|
#svg_txt ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/scriptorium/standard_files.rb', line 106
def svg_txt
<<~EOS
aspect 7.0
text.font verdana
title.color #cccccc
subtitle.color #cccccc
text.justify left
title.scale 0.8
subtitle.scale 0.4
title.style bold
subtitle.style bold italic
title.xy 5 50
subtitle.xy 5 75
back.linear #0000cc #000077 lr
EOS
end
|