design-storyboard 0.8.3 → 0.9.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29dc8b5a787823d5d17a4155906248812e57c3fd
4
- data.tar.gz: 74aa0cc54eaeab3bb31e2be874c694f55338c6ee
3
+ metadata.gz: 42fe2d78b430bef7d7ed2494940ddcb4c849284a
4
+ data.tar.gz: 4af6ad87288e8d5422a404528b24b2c585ed1032
5
5
  SHA512:
6
- metadata.gz: 0b7ef3e48f18bd0760a8fbccc7d856fe5ece59e262e6db76880706bfd8ecd7d2f590e91327dccc86dc222c189204d26346fca63ca6bd7314bda6bcf08419e3dd
7
- data.tar.gz: 3812e7997be5881e0a96bfe9889d28abd255d585fea4217d3bfcb85e8f758102c1356f578e54791a5744c8deb1f6bab543c1c7cf1b9479bac5d0bca161f26d46
6
+ metadata.gz: 4be77f001a00605d1b4b24fe51a54650b74e43b6886e7629f87a8ac1795f33757a5858c5173a95eef0622d2f9edd950f689a958d6eb6ac3d909ef9751297629c
7
+ data.tar.gz: 0831985d8b17f30588622790364936f30fcf5d49c6a69c807710fe6be6a91cdba57a02ea01597dbdb12208e14f5c0ae3f3d4ed2fcd05fb9e0ff1609f2e4b0b3f
data/README.md CHANGED
@@ -17,7 +17,7 @@ gem install design-storyboard
17
17
  # How to use?
18
18
 
19
19
  ```shell
20
- story build STORY_FILE_PATH
20
+ story build INPUT_FILE_PATH
21
21
  ```
22
22
  or try 「story help」for more information.
23
23
 
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Guanting Chen (guanting886)"]
10
10
  spec.email = ["cgt886@gmail.com"]
11
11
  spec.summary = %q{Easy to building design-storyboard.}
12
- # spec.description = %q{easy to building text-storyboard.}
13
- spec.homepage = "https://github.com/guanting886/"
12
+ spec.description = %q{這是一隻可方便您製作 操作流程、分鏡 Ruby 程式,用一般書寫文字的方式,就可以把流程細節整理好,印在網頁上及輸出PDF(詳細內容請參閱 Github Repo 上的 README 說明)}
13
+ spec.homepage = "https://github.com/guanting886/design-storyboard"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -29,8 +29,8 @@ A new command `story` was added, enjoy!
29
29
 
30
30
  $ story help
31
31
  Commands:
32
- story build [STORY_FILE_PATH] # Build storyboard (html) from story file.
33
- story build [STORY_FILE_PATH] --open # Save file and open storeboard file with browser (Mac Only)
32
+ story build [INPUT_FILE_PATH] # Build storyboard (html) from story file.
33
+ story build [INPUT_FILE_PATH] --open # Save file and open storeboard file with browser (Mac Only)
34
34
  story version # Prints version
35
35
 
36
36
  ---------------------------------------
@@ -0,0 +1,104 @@
1
+
2
+ a {
3
+ color: #0375AA;
4
+ }
5
+
6
+ a:hover {
7
+ color: orange;
8
+ }
9
+
10
+ .page-title h1 {
11
+ font-weight: normal;
12
+ text-align: center;
13
+ }
14
+
15
+ body {
16
+ font-family: \5FAE\8EDF\6B63\9ED1\9AD4, "Helvetica Neue", Helvetica, Arial,
17
+ "Hiragino Kaku Gothic ProN", "Lantinghei TC", sans-serif;
18
+
19
+ font-size: 15px;
20
+ line-height: 24px;
21
+ }
22
+
23
+ .container {
24
+ width: 1000px;
25
+ margin: 0 auto;
26
+ }
27
+
28
+ .footer {
29
+ width: 1000px;
30
+ margin: 0 auto;
31
+ text-align: center;
32
+ }
33
+
34
+ .copyright-info {
35
+ line-height: 130px;
36
+ }
37
+
38
+ .tag-1 {
39
+ color: #E8180E;
40
+ margin-left: 3px;
41
+ margin-right: 3px;
42
+ }
43
+
44
+ .tag-2 {
45
+ color: #0090FF;
46
+ }
47
+
48
+ .tag-3 {
49
+ color: green;
50
+ margin-left: 3px;
51
+ margin-right: 3px;
52
+ }
53
+
54
+ .storyboard {
55
+ width: 100%;
56
+ }
57
+
58
+ .storyboard th {
59
+ content: "xX";
60
+ }
61
+
62
+ .storyboard tr.headline td {
63
+ color: white;
64
+ background-color: #0075AA !important;
65
+ }
66
+
67
+ .storyboard td {
68
+ color: #333333;
69
+ font-size: 13px;
70
+ vertical-align: top;
71
+ border-right: 1px solid #DDDDDD;
72
+ border-bottom: 1px solid #DDDDDD;
73
+
74
+ transition-property: background-color, color;
75
+ transition-duration: 0.5s;
76
+ transition-timing-function: ease;
77
+ }
78
+
79
+ .storyboard td img {
80
+ width: 100%;
81
+ }
82
+
83
+ .storyboard tr:hover td {
84
+ color: white;
85
+ background-color: #333333 !important;
86
+ }
87
+
88
+ .storyboard .col-1 {
89
+ width: 50px;
90
+ }
91
+
92
+ .storyboard .col-2 {
93
+ width: 500px;
94
+ }
95
+
96
+ .storyboard .col-1 div {
97
+ width: 40px;
98
+ display: block;
99
+ margin: 0 auto;
100
+ }
101
+
102
+ .storyboard tr:nth-child(odd) td {
103
+ background-color: #F5F5F5;
104
+ }
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'fileutils'
3
4
  require 'design_storyboard'
4
5
  require 'thor'
5
6
  require 'design_storyboard/version'
@@ -8,9 +9,9 @@ module DesignStoryboard
8
9
  class Cli < Thor
9
10
 
10
11
  option :open, :type => :boolean
11
- desc 'build [STORY_FILE_PATH] --open', 'Build storyboard (html) from file.'
12
+ desc 'build [INPUT_FILE_PATH] --open', 'Build storyboard (html) from file.'
12
13
  def build(path)
13
- Setting[:story_file_path] = path
14
+ Setting[:input_file_path] = path
14
15
  Setting.update_dump_data_path
15
16
  Setting[:auto_open] = true if options[:open]
16
17
 
@@ -2,6 +2,21 @@
2
2
 
3
3
  module DesignStoryboard
4
4
  module Export
5
+ @storyboard_cols_count = 0
6
+
7
+ REGEXP_RULE_FOR_FIND_LINK = /
8
+ (?:link|url):[[:blank:]]*(?<uri>[\w\_\-]+:\/\/[\S]+)
9
+ /xi
10
+
11
+ REGEXP_RULE_FOR_FIND_LINK_AND_TITLE = /
12
+ (?:link|url):[[:blank:]]*(?<uri>[\w\_\-]+:\/\/[\S]+)
13
+ [[:blank:]]*\|[[:blank:]]*
14
+ (?:caption|title):[[:blank:]]*(?<title>[\S]+)
15
+ /xi
16
+
17
+ REGEXP_RULE_FOR_FIND_IMAGE = /
18
+ (?:images|image|img|picture|pic):[[:blank:]]*(?<uri>[\w\_\-]+:\/\/[\S]+)
19
+ /xi
5
20
 
6
21
  def apply_html_template(title, html_syntax)
7
22
  html = %Q(
@@ -9,12 +24,19 @@ module DesignStoryboard
9
24
  <html>
10
25
  <head>
11
26
  <meta charset="utf-8">
27
+ <title>#{title} by Design Storyboard</title>
12
28
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
13
- <link rel="stylesheet" href="css/storyboard.css">
29
+ <link rel="stylesheet" href="#{Setting[:stylesheet_path]}">
14
30
  </head>
15
31
  <body>
16
32
  <div class="page-title"><h1>#{title}</h1></div>
17
33
  <div class="container">#{html_syntax}</div>
34
+ <div class="footer">
35
+ <div class="copyright-info">Powered by
36
+ <a target="_blank" href="https://github.com/guanting886/design-storyboard">Design Storyboard</a>
37
+ 節省您作業時間的好工具 😎
38
+ </div>
39
+ </div>
18
40
  </body>
19
41
  </html>
20
42
  )
@@ -24,22 +46,34 @@ module DesignStoryboard
24
46
  html = '<tr>'
25
47
 
26
48
  args.each_with_index do |value, index|
27
- value.gsub!(/[\r\n]+/, '<br>')
49
+
28
50
  value.gsub!(/\[(?<tag1>[^\]]+)\]/, '<span class="tag-1">[\k<tag1>]</span>')
29
51
  value.gsub!(/\「(?<tag2>[^\」]+)\」/, '<span class="tag-2">「\k<tag2>」</span>')
30
52
  value.gsub!(/\((?<tag3>[^\」]+)\)/, '<span class="tag-3">(\k<tag3>)</span>')
31
53
  value.gsub!(/\((?<tag3>[^\」]+)\)/, '<span class="tag-3">(\k<tag3>)</span>')
32
- html << "<td class='td-#{index}'><div>#{value}</div></td>"
54
+ value.gsub!(REGEXP_RULE_FOR_FIND_LINK_AND_TITLE, '<a href="\k<uri>" target="_blank">\k<title></a>')
55
+ value.gsub!(REGEXP_RULE_FOR_FIND_LINK, '<a href="\k<uri>" target="_blank">\k<uri></a>')
56
+ value.gsub!(REGEXP_RULE_FOR_FIND_IMAGE, '<img src="\k<uri>">')
57
+
58
+ value.gsub!(/[\r\n]+/, '<br>')
59
+
60
+ html << "<td class='col-#{index+1}'><div>#{value}</div></td>"
33
61
  end
34
62
 
35
63
  html << '</tr>'
36
64
  end
37
65
 
66
+ def generate_table_headline(title)
67
+ "<tr class='headline'><td colspan='#{@storyboard_cols_count}'>#{title}</td></tr>"
68
+ end
69
+
38
70
  def generate_table_header(*args)
71
+ @storyboard_cols_count = args.length
72
+
39
73
  html = '<tr>'
40
74
 
41
- args.each do |value|
42
- html << "<th>#{value}</th>"
75
+ args.each_with_index do |value, index|
76
+ html << "<th class='col-#{index+1}'>#{value}</th>"
43
77
  end
44
78
 
45
79
  html << '</tr>'
@@ -60,8 +94,15 @@ module DesignStoryboard
60
94
  table_header_html = generate_table_header('Step', 'Description', 'Note')
61
95
  table_cells_html = ""
62
96
 
63
- info_collection.each do |index, info|
64
- table_cells_html << generate_table_cell(info[:step], info[:description], info[:note])
97
+ info_collection.each do |info|
98
+
99
+ if info.is_a? Hash
100
+ table_cells_html << generate_table_cell(info[:step], info[:description], info[:note])
101
+ elsif info.is_a? String
102
+ table_cells_html << generate_table_headline(info)
103
+ else
104
+ # ignore
105
+ end
65
106
  end
66
107
 
67
108
  table_html = generate_table(table_header_html, table_cells_html)
@@ -82,9 +123,17 @@ module DesignStoryboard
82
123
  title 'Here you are'
83
124
  attention Setting[:dump_file_path]
84
125
 
126
+ create_css if Setting[:auto_create_css]
85
127
  open_browser if Setting[:auto_open]
86
128
  end
87
129
 
130
+ def create_css
131
+ assets_dir_css_path = File.join(Setting[:assets_path], Setting[:stylesheet_dir_name], Setting[:stylesheet_file_name])
132
+ release_dir_css_path = File.join(Setting[:dump_dir_path], Setting[:stylesheet_dir_name], Setting[:stylesheet_file_name])
133
+
134
+ FileUtils.cp assets_dir_css_path, release_dir_css_path if not File.exist? release_dir_css_path
135
+ end
136
+
88
137
  def open_browser
89
138
  `open "#{Setting[:dump_file_path]}"`
90
139
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DesignStoryboard
4
+
4
5
  module Setting
5
6
 
6
7
  @settings = {}
@@ -17,20 +18,37 @@ module DesignStoryboard
17
18
  all[key] = value
18
19
  end
19
20
 
21
+ def self.create_important_folder
22
+ FileUtils.mkpath File.join(Setting[:dump_dir_path])
23
+ FileUtils.mkpath File.join(Setting[:dump_dir_path], Setting[:stylesheet_dir_name]) if Setting[:auto_create_css]
24
+ end
25
+
20
26
  def self.update_dump_data_path
21
- Setting[:dump_file_path] = "#{Setting[:story_file_path]}.html"
27
+ new_filename = File.basename(Setting[:input_file_path], ".*")
28
+
29
+ Setting[:dump_dir_path] = File.join(File.dirname(Setting[:input_file_path]), Setting[:release_dir_name])
30
+ Setting[:dump_file_path] = File.join(Setting[:dump_dir_path], "#{new_filename}.html")
31
+
32
+ create_important_folder
22
33
 
23
34
  update_page_title
24
35
  end
25
36
 
26
37
  def self.update_page_title
27
- Setting[:page_title] = File.basename(Setting[:story_file_path], ".*")
38
+ Setting[:page_title] = File.basename(Setting[:input_file_path], ".*")
28
39
  end
29
40
 
30
41
  end
31
42
 
32
- Setting[:story_file_path] = ''
33
- Setting[:dump_file_path] = ''
34
- Setting[:page_title] = ''
35
- Setting[:auto_open] = false
43
+ Setting[:release_dir_name] = 'release'
44
+ Setting[:stylesheet_dir_name] = 'css'
45
+ Setting[:stylesheet_file_name] = 'storyboard.css'
46
+ Setting[:stylesheet_path] = File.join(Setting[:stylesheet_dir_name], Setting[:stylesheet_file_name])
47
+ Setting[:assets_path] = File.join(File.dirname(__FILE__), 'assets')
48
+ Setting[:input_file_path] = ''
49
+ Setting[:dump_dir_path] = ''
50
+ Setting[:dump_file_path] = ''
51
+ Setting[:page_title] = ''
52
+ Setting[:auto_open] = false
53
+ Setting[:auto_create_css] = true
36
54
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DesignStoryboard
4
- VERSION = "0.8.3"
4
+ VERSION = "0.9.5"
5
5
  end
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
-
3
2
  require 'design_storyboard/ext'
4
3
  require 'design_storyboard/export'
5
4
  require 'design_storyboard/log'
@@ -23,43 +22,50 @@ module DesignStoryboard
23
22
  def generate_storyboard_from_story_file
24
23
  start
25
24
 
26
- storyboard = {}
27
- scene = { step: '', description: '', note: '' }
28
- step_number = ""
25
+ story_collection = {}
26
+ headline_collection = {}
27
+ story = { step: '', description: '', note: '' }
28
+ step_number = "0"
29
29
  step_number_is_found = false
30
30
  note_number_is_found = false
31
31
 
32
32
  alert 'Start analyzing.'
33
33
 
34
- IO.foreach(Setting[:story_file_path]) do |data|
34
+ IO.foreach(Setting[:input_file_path]) do |data|
35
35
  data = data.remove_white_char
36
- scene_number_info = data.match(/step[[:blank:]]+(?<scene_number>[\d\-]+)\:/i)
37
- note_number_info = data.match(/\^{4}[[:blank:]]+(?<scene_number>[\d\-]+)\:/i)
36
+ match_step_number = data.match(/step[[:blank:]]+(?<step_number>[\d\-]+)\:/i)
37
+ match_note_number = data.match(/(?:note|\^{4})[[:blank:]]+(?<step_number>[\d\-]+)\:/i)
38
+ match_headline = data.match(/\={4,}[[:blank:]]*(?<headline>[\S]+)[[:blank:]]*\={4,}/i)
39
+
40
+ if match_headline.present?
41
+ headline_collection[step_number] = match_headline[:headline]
42
+ next
43
+ end
38
44
 
39
- if scene_number_info.present?
45
+ if match_step_number.present?
40
46
  step_number_is_found = true
41
47
  note_number_is_found = false
42
48
 
43
- step_number = scene_number_info[1]
44
- storyboard[step_number] = scene.dup
45
- storyboard[step_number][:step] = step_number
46
- storyboard[step_number][:description] = ""
49
+ step_number = match_step_number[:step_number]
50
+ story_collection[step_number] = story.dup
51
+ story_collection[step_number][:step] = step_number
52
+ story_collection[step_number][:description] = ""
47
53
 
48
54
  say "catch <- #{step_number}"
49
55
 
50
- elsif note_number_info.present?
56
+ elsif match_note_number.present?
51
57
  step_number_is_found = false
52
58
  note_number_is_found = true
53
59
 
54
- storyboard[step_number][:note] = ""
60
+ story_collection[step_number][:note] = ""
55
61
 
56
62
  say "catch note <- #{step_number}"
57
63
 
58
64
  elsif step_number_is_found
59
- storyboard[step_number][:description] << data
65
+ story_collection[step_number][:description] << data
60
66
 
61
67
  elsif note_number_is_found
62
- storyboard[step_number][:note] << data
68
+ story_collection[step_number][:note] << data
63
69
 
64
70
  else
65
71
  # ignore
@@ -67,10 +73,34 @@ module DesignStoryboard
67
73
  end
68
74
 
69
75
  done
76
+
70
77
  rescue Exception => e
71
78
  runtime_error e
72
79
  ensure
73
- return storyboard
80
+ return make_storyboard(headline_collection, story_collection)
81
+ end
82
+
83
+ def make_storyboard(headline_collection, story_collection)
84
+ storyboard = []
85
+
86
+ if headline_collection.present?
87
+ if headline_collection.has_key? "0"
88
+ storyboard.push headline_collection["0"]
89
+ headline_collection.delete("0")
90
+ end
91
+ end
92
+
93
+ story_collection.each do |index, story|
94
+ storyboard.push story
95
+
96
+ step_number = story[:step]
97
+
98
+ if headline_collection.has_key? step_number
99
+ storyboard.push headline_collection[step_number]
100
+ end
101
+ end
102
+
103
+ storyboard
74
104
  end
75
105
 
76
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: design-storyboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guanting Chen (guanting886)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.18'
55
- description:
55
+ description: "這是一隻可方便您製作 操作流程、分鏡 的 Ruby 程式,用一般書寫文字的方式,就可以把流程細節整理好,印在網頁上及輸出PDF(詳細內容請參閱
56
+ Github Repo 上的 README 說明)"
56
57
  email:
57
58
  - cgt886@gmail.com
58
59
  executables:
@@ -68,13 +69,14 @@ files:
68
69
  - bin/story
69
70
  - design_storyboard.gemspec
70
71
  - lib/design_storyboard.rb
72
+ - lib/design_storyboard/assets/css/storyboard.css
71
73
  - lib/design_storyboard/cli.rb
72
74
  - lib/design_storyboard/export.rb
73
75
  - lib/design_storyboard/ext.rb
74
76
  - lib/design_storyboard/log.rb
75
77
  - lib/design_storyboard/setting.rb
76
78
  - lib/design_storyboard/version.rb
77
- homepage: https://github.com/guanting886/
79
+ homepage: https://github.com/guanting886/design-storyboard
78
80
  licenses:
79
81
  - MIT
80
82
  metadata: {}
@@ -85,8 +87,8 @@ post_install_message: |
85
87
 
86
88
  $ story help
87
89
  Commands:
88
- story build [STORY_FILE_PATH] # Build storyboard (html) from story file.
89
- story build [STORY_FILE_PATH] --open # Save file and open storeboard file with browser (Mac Only)
90
+ story build [INPUT_FILE_PATH] # Build storyboard (html) from story file.
91
+ story build [INPUT_FILE_PATH] --open # Save file and open storeboard file with browser (Mac Only)
90
92
  story version # Prints version
91
93
 
92
94
  ---------------------------------------