WWWCHtmlConverter 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <diagram>
3
+ <page_setting>
4
+ <direction_horizontal>true</direction_horizontal>
5
+ <scale>100</scale>
6
+ <paper_size>A4 210 x 297 mm</paper_size>
7
+ <top_margin>30</top_margin>
8
+ <left_margin>30</left_margin>
9
+ <bottom_margin>30</bottom_margin>
10
+ <right_margin>30</right_margin>
11
+ </page_setting>
12
+ <category_index>0</category_index>
13
+ <zoom>1.0</zoom>
14
+ <x>0</x>
15
+ <y>0</y>
16
+ <default_color>
17
+ <r>128</r>
18
+ <g>128</g>
19
+ <b>192</b>
20
+ </default_color>
21
+ <color>
22
+ <r>255</r>
23
+ <g>255</g>
24
+ <b>255</b>
25
+ </color>
26
+ <font_name>メイリオ</font_name>
27
+ <font_size>9</font_size>
28
+ <settings>
29
+ <database>MSAccess</database>
30
+ <capital>false</capital>
31
+ <table_style></table_style>
32
+ <notation></notation>
33
+ <notation_level>0</notation_level>
34
+ <notation_expand_group>true</notation_expand_group>
35
+ <view_mode>1</view_mode>
36
+ <outline_view_mode>1</outline_view_mode>
37
+ <view_order_by>1</view_order_by>
38
+ <auto_ime_change>false</auto_ime_change>
39
+ <validate_physical_name>true</validate_physical_name>
40
+ <use_bezier_curve>false</use_bezier_curve>
41
+ <suspend_validator>false</suspend_validator>
42
+ <export_setting>
43
+ <export_ddl_setting>
44
+ <output_path></output_path>
45
+ <encoding></encoding>
46
+ <line_feed></line_feed>
47
+ <is_open_after_saved>true</is_open_after_saved>
48
+ <environment_id>null</environment_id>
49
+ <category_id>null</category_id>
50
+ <ddl_target>
51
+ <create_comment>true</create_comment>
52
+ <create_foreignKey>true</create_foreignKey>
53
+ <create_index>true</create_index>
54
+ <create_sequence>true</create_sequence>
55
+ <create_table>true</create_table>
56
+ <create_tablespace>true</create_tablespace>
57
+ <create_trigger>true</create_trigger>
58
+ <create_view>true</create_view>
59
+ <drop_index>true</drop_index>
60
+ <drop_sequence>true</drop_sequence>
61
+ <drop_table>true</drop_table>
62
+ <drop_tablespace>true</drop_tablespace>
63
+ <drop_trigger>true</drop_trigger>
64
+ <drop_view>true</drop_view>
65
+ <inline_column_comment>true</inline_column_comment>
66
+ <inline_table_comment>true</inline_table_comment>
67
+ <comment_value_description>true</comment_value_description>
68
+ <comment_value_logical_name>false</comment_value_logical_name>
69
+ <comment_value_logical_name_description>false</comment_value_logical_name_description>
70
+ <comment_replace_line_feed>false</comment_replace_line_feed>
71
+ <comment_replace_string></comment_replace_string>
72
+ </ddl_target>
73
+ </export_ddl_setting>
74
+ <export_excel_setting>
75
+ <category_id>null</category_id>
76
+ <output_path></output_path>
77
+ <template></template>
78
+ <template_path></template_path>
79
+ <used_default_template_lang></used_default_template_lang>
80
+ <image_output></image_output>
81
+ <is_open_after_saved>true</is_open_after_saved>
82
+ <is_put_diagram>true</is_put_diagram>
83
+ <is_use_logical_name>true</is_use_logical_name>
84
+ </export_excel_setting>
85
+ <export_html_setting>
86
+ <output_dir></output_dir>
87
+ <with_category_image>true</with_category_image>
88
+ <with_image>true</with_image>
89
+ <is_open_after_saved>true</is_open_after_saved>
90
+ </export_html_setting>
91
+ <export_image_setting>
92
+ <output_file_path></output_file_path>
93
+ <category_dir_path></category_dir_path>
94
+ <with_category_image>true</with_category_image>
95
+ <is_open_after_saved>true</is_open_after_saved>
96
+ </export_image_setting>
97
+ <export_java_setting>
98
+ <java_output></java_output>
99
+ <package_name></package_name>
100
+ <class_name_suffix></class_name_suffix>
101
+ <src_file_encoding></src_file_encoding>
102
+ <with_hibernate>false</with_hibernate>
103
+ </export_java_setting>
104
+ <export_testdata_setting>
105
+ <file_encoding></file_encoding>
106
+ <file_path></file_path>
107
+ <format>0</format>
108
+ </export_testdata_setting>
109
+ </export_setting>
110
+ <category_settings>
111
+ <free_layout>false</free_layout>
112
+ <show_referred_tables>false</show_referred_tables>
113
+ <categories>
114
+ </categories>
115
+ </category_settings>
116
+ <translation_settings>
117
+ <use>true</use>
118
+ <translations>
119
+ <translation>
120
+ <name>デフォルト</name>
121
+ </translation>
122
+ </translations>
123
+ </translation_settings>
124
+ <model_properties>
125
+ <id></id>
126
+ <height>-1</height>
127
+ <width>-1</width>
128
+ <font_name></font_name>
129
+ <font_size>9</font_size>
130
+ <x>50</x>
131
+ <y>50</y>
132
+ <connections>
133
+ </connections>
134
+ <display>false</display>
135
+ <creation_date>2018-03-14 16:26:24</creation_date>
136
+ <updated_date>2018-03-14 16:26:24</updated_date>
137
+ <model_property>
138
+ <name>プロジェクト名</name>
139
+ <value></value>
140
+ </model_property>
141
+ <model_property>
142
+ <name>モデル名</name>
143
+ <value></value>
144
+ </model_property>
145
+ <model_property>
146
+ <name>バージョン</name>
147
+ <value></value>
148
+ </model_property>
149
+ <model_property>
150
+ <name>会社名</name>
151
+ <value></value>
152
+ </model_property>
153
+ <model_property>
154
+ <name>作成者</name>
155
+ <value></value>
156
+ </model_property>
157
+ </model_properties>
158
+ <table_properties>
159
+ <schema></schema>
160
+ </table_properties>
161
+ <environment_setting>
162
+ </environment_setting>
163
+ </settings>
164
+ <dictionary>
165
+ </dictionary>
166
+ <tablespace_set>
167
+ </tablespace_set>
168
+ <contents>
169
+ </contents>
170
+ <column_groups>
171
+ </column_groups>
172
+ <test_data_list>
173
+ </test_data_list>
174
+ <sequence_set>
175
+ </sequence_set>
176
+ <trigger_set>
177
+ </trigger_set>
178
+ <change_tracking_list>
179
+ </change_tracking_list>
180
+ </diagram>
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "WWWCHtmlConverter/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "WWWCHtmlConverter"
8
+ spec.version = WWWCHtmlConverter::VERSION
9
+ spec.authors = ["ShiccaRorl"]
10
+ spec.email = ["shicca.rorl@gmail.com"]
11
+
12
+ spec.summary = %q{WWWC → db → html}
13
+ spec.description = %q{WWWC → db → html Converter}
14
+ spec.homepage = "https://rubygems.org/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_dependency 'thor'
38
+
39
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "WWWCHtmlConverter"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "WWWCHtmlConverter"
@@ -0,0 +1,350 @@
1
+ # -*- encoding: utf-8 -*-
2
+ p 'index'
3
+ p 'a'.encoding
4
+
5
+ require "erb"
6
+ require "thor"
7
+
8
+ module WWWCHTMLConverter
9
+ # Your code goes here...
10
+ class CommandLine < Thor
11
+ attr_accessor :wwwc
12
+ desc "in WWWwwCのディレクトリ", "out アウトプットディレクトリ"
13
+ def initialize()
14
+ @wwwc = WWWC.new()
15
+ end
16
+
17
+ def in(dir_path)
18
+ @wwwc.dir_path_in = dir_path
19
+ end
20
+
21
+ def out(dir_path)
22
+ @wwwc.dir_path_out = dir_path
23
+ end
24
+ end
25
+
26
+ class WWWCHTMLConverter
27
+ def initialize()
28
+ @commandline = CommandLine.new()
29
+ end
30
+ end
31
+
32
+ class WWWC
33
+ attr_accessor :file_path, :dir_path, :dir_path_out, :dir_path_split, :file_name, :dir_list, :item_list
34
+ def initialize()
35
+ @file_path = ""
36
+ @dir_path_in = ""
37
+ @dir_path_out = ""
38
+ @dir_path_split = []
39
+ @file_name = ""
40
+ @dir_list = DirList.new(@dir_path)
41
+ @item_list = ItemList.new(@file_path)
42
+
43
+ end
44
+ end
45
+
46
+ class DirList
47
+ def initialize(dir_path)
48
+
49
+ end
50
+ end
51
+
52
+ class ItemList
53
+ def initialize(file_path)
54
+
55
+ end
56
+ end
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ class Link
65
+ def initialize(wwwc_path, html_path)
66
+ if wwwc_path == nil or html_path == nil then
67
+ help()
68
+ return 0
69
+ end
70
+
71
+ if Dir::exist?(wwwc_path) == true and Dir::exist?(html_path) == true then
72
+
73
+ if File::ftype(wwwc_path) == "directory" then
74
+ p wwwc_path.encode(Encoding::SJIS) + "WWWCのディレクトリではないです".encode(Encoding::SJIS)
75
+ return 0
76
+ end
77
+
78
+ if File::ftype(html_path) == "directory" then
79
+ p html_path.encode(Encoding::SJIS) + "Linkのディレクトリではないです".encode(Encoding::SJIS)
80
+ return 0
81
+ end
82
+
83
+ end
84
+
85
+ @wwwc = WWWC_HTML_Converter.new
86
+
87
+ # Item.datのパスを回帰的に取得
88
+ @items = []
89
+ Dir.glob("Item.dat/**/*").each{|dir|
90
+ wwwc = WWWC_HTML_Converter.new
91
+ wwwc.item_date_pach = dir
92
+ pp dir.encode(Encoding::SJIS)
93
+ }
94
+
95
+ # ディレクトリリスト作成
96
+ @items.each{|wwwc|
97
+ dir_list = Dir::entries()
98
+ dir_list.each{|dir|
99
+ if File::ftype(dir) == true then
100
+ wwwc.dir_list << dir
101
+ end
102
+ }
103
+ }
104
+
105
+ @items.each{|wwwc|
106
+ f = File.open(wwwc.item_dat_pach, 'r:utf-8'){|f|
107
+ @source = f.read # 全て読み込む
108
+ }
109
+
110
+ }
111
+ end
112
+
113
+ def help()
114
+ p "WWWC_HTML_Converter.exe wwwc_path html_path"
115
+ end
116
+ end
117
+
118
+ class Item
119
+ def initiarize()
120
+
121
+ end
122
+ end
123
+
124
+ class Day
125
+ attr_accessor :day, :daytiem, :title, :log
126
+ def initialize(data)
127
+ @data = data
128
+ @datetime = ""
129
+ @title = ""
130
+ @log = ""
131
+
132
+ # データが有るかチェックする
133
+ if @data[:Datetime] == nil then
134
+ p "日付無し".encode(Encoding::SJIS)
135
+ @data[:Datetime] = Time.now
136
+ end
137
+ if @data[:Title] == nil then
138
+ p "タイトル無し".encode(Encoding::SJIS)
139
+ @data[:Title] = ""
140
+ end
141
+ if @data[:Log] == nil then
142
+ p "ログ無し".encode(Encoding::SJIS)
143
+ @data[:Log] = ""
144
+ end
145
+ # データをUTP-8に変換
146
+ begin
147
+ p "===================================="
148
+ p "day :" + @data[:Datetime].strftime("%Y-%m-%d %H:%M:%S (%A)")
149
+ p "title :" + @data[:Title].encode(Encoding::SJIS)
150
+ #p "log " + day[:Log].encode(Encoding::SJIS)
151
+ @data[:Title].encode!("UTF-8")
152
+ @data[:Log].encode!("UTF-8")
153
+ rescue
154
+ p "UTF-8 変換エラー"#.encode(Encoding::SJIS)
155
+ end
156
+
157
+ # 改行文字変換
158
+ if @data[:Log] != nil then
159
+ @data[:Log].gsub!(/(\r\n|\r\f\n|\r|\n)/, "</p>\n<p>")
160
+ end
161
+
162
+ # データの代入
163
+ @datetime = @data[:Datetime]
164
+ @title = @data[:Title]
165
+ @log = @data[:Log]
166
+
167
+ @data_db = [@datetime, @title, @log]
168
+
169
+ end
170
+
171
+ def get_data_db()
172
+ return @data_db
173
+ end
174
+
175
+ def get_Datetime()
176
+ return @data_db[0]
177
+ end
178
+
179
+ def get_day_s()
180
+ return @data_db[0].strftime("%Y-%m-%d")
181
+ end
182
+
183
+ def get_Datetime_s()
184
+ return @data_db[0].strftime("%Y-%m-%d %H:%M:%S (%A)")
185
+ end
186
+
187
+ def get_tile()
188
+ return @data_db[1]
189
+ end
190
+
191
+ def get_log()
192
+ return @data_db[2]
193
+ end
194
+ end
195
+
196
+ class Days
197
+ attr_accessor :days
198
+ def initialize(db)
199
+ @db = db
200
+ @days = []
201
+
202
+ @db.each{|day_data|
203
+ day = Day.new(day_data)
204
+ @days << day
205
+ }
206
+ @days.sort!{|a, b| b.get_Datetime_s() <=> a.get_Datetime_s() }
207
+ end
208
+
209
+ def get_days()
210
+ return @days
211
+ end
212
+
213
+ # 重複日付を消したデータ
214
+ def sort_data()
215
+
216
+ # 日付だけのデータを作ります
217
+ @days_time = []
218
+ @days.each{|day|
219
+ @days_time << day.get_day_s()
220
+ }
221
+ return @days_time.uniq!
222
+ end
223
+ end
224
+
225
+ class Index
226
+ attr_accessor :db, :keywords, :keyword, :css_theme_path, :link, :hiduke, :day, :title
227
+ def initialize()
228
+ # コンフィング
229
+ # main file
230
+ @thml_path = "./../../html/" # 出力ディレクトリ
231
+ @file_name = "index.html" # 出力ファイル
232
+ @css_path = "./theme/" # テーマディレクトリ
233
+ @css_theme = "3minutes" # テーマ
234
+ @day_hach_path = "./../../html/index/" # コラム出力ディレクトリ
235
+ @day_hach = {} # コラムを入れる
236
+
237
+ dir_css = Dir.glob('./../../html/theme/*')
238
+ @css_theme = dir_css[rand(dir_css.size)].sub!("./../../html/theme/", "")
239
+
240
+ # データベース
241
+ @db_file_name = ARGV[0]
242
+ @db = Sequel.sqlite(@db_file_name)
243
+
244
+ # データベースからデータ取得
245
+ dataset = @db[:index].where(:Private => false).order(:Datetime)
246
+ datas = dataset.all
247
+
248
+ @days = Days.new(datas)
249
+
250
+ @css_theme_path = @css_path + @css_theme + "/" + @css_theme + ".css"
251
+
252
+ moto = []
253
+ Dir.glob("./*.jpg").each{|i| moto << i}
254
+ Dir.glob("./*.png").each{|i| moto << i}
255
+ Dir.glob("./*.gif").each{|i| moto << i}
256
+ #FileUtils.cp(moto, @thml_pach)
257
+
258
+ @header = File.open("./../header.erb").read
259
+ @footer = File.open("./../footer.erb").read
260
+ @body = File.open("./../body.erb").read
261
+ @day_body = File.open("./../day_body.erb").read
262
+ @all_body = File.open("./../all_body.erb").read
263
+
264
+ end
265
+
266
+ def keyword()
267
+ @keywords = @db[:keyword].select(:Keyword).all
268
+
269
+ @keyword = ""
270
+ @keywords.each{|i|
271
+ i.each{|key, value|
272
+ @keyword = value + ", " + @keyword}
273
+ }
274
+ @keyword.encode!("UTF-8")
275
+ end
276
+
277
+ def create_body()
278
+ # くっつける
279
+
280
+ @htmls = []
281
+ @days.get_days().each{|day|
282
+ html = @header + @body + @footer
283
+ @htmls << [day.get_day_s(), day.get_tile(), html] # くっつける
284
+ }
285
+
286
+ @htmls.each{|day_time, tile, body|
287
+ erb = ERB.new(body)
288
+ @htmls << [day_time, tile, erb.result(binding)] # ファイル名とhtmlの配列
289
+ }
290
+ file_save()
291
+ end
292
+
293
+ def day_create_body()
294
+ @days.sort_data().each{|day_s| # 文字列だけのデータ
295
+ @daydata = []
296
+ @days.get_days.each{|day|
297
+ if day_s == day.get_day_s() then
298
+ @daydata << day
299
+ else
300
+ #@daydata << day
301
+ end
302
+ @daydata.sort!{|a, b| a.get_Datetime() <=> b.get_Datetime() }
303
+ @css_path = "./../theme/"
304
+ @css_theme_path = @css_path + @css_theme + "/" + @css_theme + ".css"
305
+ htmls = @header + @body + @footer
306
+ erb = ERB.new(htmls)
307
+ html = erb.result(binding)
308
+ # ファイル書き込み
309
+ begin
310
+ File.write(@thml_path + "index/" + day_s + ".html", html)
311
+ rescue
312
+ p day_s + ".html"
313
+ p "ファイル書き込みエラー".encode(Encoding::SJIS)
314
+ end
315
+ }
316
+ }
317
+ end
318
+
319
+ def all_create_body()
320
+
321
+ htmls = @header + @all_body + @footer
322
+
323
+ erb = ERB.new(htmls)
324
+ html = erb.result(binding)
325
+
326
+ # ファイル書き込み
327
+ File.write(@thml_path + @file_name, html)
328
+ end
329
+
330
+ def create_html()
331
+ keyword() # キーワード作成
332
+
333
+ p "HTMLデータ作成".encode(Encoding::SJIS)
334
+ #create_body() # html作成
335
+ all_create_body() # 日付ごとのHTML作成
336
+ day_create_body() # 日付ごとのHTML作成
337
+
338
+ end
339
+
340
+ def file_save()
341
+ # ファイル書き込み
342
+ @days.get_days.each{|day_name, title, html|
343
+ File.write(@thml_path + @file_name, html)
344
+ }
345
+ end
346
+ end
347
+ end
348
+
349
+ link = WWWC_HTML_Converter::Link.new(ARGV[0], ARGV[1]) #
350
+
@@ -0,0 +1,3 @@
1
+ module WWWCHtmlConverter
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require "WWWCHtmlConverter/version"
4
+ require "WWWCHtmlConverter/WWWCHtmlConverter"
5
+
6
+
7
+ module WWWCHtmlConverter
8
+
9
+ # Your code goes here...
10
+ end
11
+
12
+ wwwc_html_converter = WWWCHTMLConverter::WWWCHTMLConverter
13
+