tocmd 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ff43dfdf1ed5218f0ec1bee189ffd7ccfa93cae
4
- data.tar.gz: e01d0870d289de98e83f09c92062a867c2f640a5
3
+ metadata.gz: 2c3044c33c4167f29d7f84519de72e1cbeebc85d
4
+ data.tar.gz: 38d60afad5ec3e90392f971f4c69e6aff6d2ed8c
5
5
  SHA512:
6
- metadata.gz: e2fef44afcdd498bbfa2107a5e7c432e21360a7d40d00999baff0b9fc563ec64a82ecb41177b73804579cb972306846924245775421c70226588214eefbb0238
7
- data.tar.gz: 3f1d320b1cf38482101cca267cf69728109ef881355a32bf1d6bd96e927b19dd45c9d5223680d4cc1b0548f4d382cb9b806e0c216ff8ba34f193fba6539a7dc7
6
+ metadata.gz: ccea96c5752a5687c202b17f810f2f2b857ded8c2126f3d8b6c2ff80f5fed46292131fb61552bc8d3c651b3b569d05d6ea8d42e581e1ced5e07e25676e691117
7
+ data.tar.gz: 408048591420c5904f1109a9249b5fdeadae99aa570fd4e28390fa36cfcb1ebea33a56fcfe571efe688f8355126dd4b82d4bf129dec4bba53e4bb9e9c81d75f8
@@ -1,6 +1,7 @@
1
1
  require 'pathname'
2
2
  # require 'FileUtils'
3
3
  require 'fileutils'
4
+ require 'os'
4
5
 
5
6
  class Tocmd::Translator
6
7
  def initialize(source_file_path)
@@ -55,28 +56,21 @@ class Tocmd::Translator
55
56
 
56
57
  def open_in_browser
57
58
  ar = @source_file_path.split('/')
59
+ src_path = ar.join('/').to_s
58
60
 
59
61
  if File.directory?(@source_file_path) == false #普通文件
60
- file_name = ar.pop().split('.')[0]
61
- src_path = ar.join('/').to_s
62
-
63
- ar.push('preview');
64
- dest_dir = ar.join('/').to_s
65
-
66
- `open #{ar.join('/').to_s}/#{file_name}.html`
67
-
62
+ file_name = ar.pop().split('.')[0]
68
63
  else
69
- # 目录
70
- src_path = ar.join('/').to_s
71
-
72
64
  Dir.foreach(src_path) do |ff|
73
65
  file_name = ff.split('.')[0]
74
- end
75
-
76
- ar.push('preview');
77
- dest_dir = ar.join('/').to_s
78
- `open #{ar.join('/').to_s}/#{file_name}.html`
66
+ end
79
67
  end
68
+
69
+ ar.push('preview');
70
+ dest_dir = ar.join('/').to_s
71
+ open_file_name = "#{ar.join('/').to_s}/#{file_name}.html"
72
+
73
+ OS.linux? ? `xdg-open #{ open_file_name }` : `open #{ open_file_name }`
80
74
  end
81
75
 
82
76
  def generate_meta_js
@@ -1,6 +1,7 @@
1
1
  require 'pathname'
2
2
  # require 'FileUtils'
3
3
  require 'fileutils'
4
+ require 'os'
4
5
 
5
6
  class Tocmd::TranslatorConf
6
7
  def initialize(source_file_path)
@@ -31,7 +32,7 @@ class Tocmd::TranslatorConf
31
32
  # copy vendor/toc to dest directory
32
33
  `cp -rf #{@editor_path}/toc #{dest_dir}`
33
34
 
34
- # _toc_config(dest_dir)
35
+ _toc_config(dest_dir)
35
36
 
36
37
  # build now
37
38
  build_with_dir(@source_file_path ,dest_dir)
@@ -58,7 +59,7 @@ class Tocmd::TranslatorConf
58
59
  # copy vendor/toc to dest directory
59
60
  `cp -rf #{@editor_path}/toc #{dest_dir}/toc`
60
61
 
61
- # _toc_config(dest_dir)
62
+ _toc_config(dest_dir)
62
63
 
63
64
  build_with_dir(src_path ,dest_dir)
64
65
 
@@ -85,28 +86,21 @@ class Tocmd::TranslatorConf
85
86
 
86
87
  def open_in_browser
87
88
  ar = @source_file_path.split('/')
89
+ src_path = ar.join('/').to_s
88
90
 
89
91
  if File.directory?(@source_file_path) == false #普通文件
90
- file_name = ar.pop().split('.')[0]
91
- src_path = ar.join('/').to_s
92
-
93
- ar.push('preview');
94
- dest_dir = ar.join('/').to_s
95
-
96
- `open #{ar.join('/').to_s}/#{file_name}.html`
97
-
92
+ file_name = ar.pop().split('.')[0]
98
93
  else
99
- # 目录
100
- src_path = ar.join('/').to_s
101
-
102
94
  Dir.foreach(src_path) do |ff|
103
95
  file_name = ff.split('.')[0]
104
96
  end
105
-
106
- ar.push('preview');
107
- dest_dir = ar.join('/').to_s
108
- `open #{ar.join('/').to_s}/#{file_name}.html`
109
97
  end
98
+
99
+ ar.push('preview');
100
+ dest_dir = ar.join('/').to_s
101
+ open_file_name = "#{ ar.join('/').to_s}/#{file_name}.html"
102
+
103
+ OS.linux? ? `xdg-open #{ open_file_name }` : ` open #{ open_file_name }`
110
104
  end
111
105
 
112
106
  def generate_meta_js
@@ -252,7 +246,7 @@ class Tocmd::TranslatorConf
252
246
  <script type="text/javascript" src="toc/js/jquery-1.4.4.min.js"></script>
253
247
  <script type="text/javascript" src="toc/js/jquery.ztree.all-3.5.min.js"></script>
254
248
  <script type="text/javascript" src="toc/js/ztree_toc.js"></script>
255
- <script type="text/javascript" src="toc/toc_conf.js"></script>
249
+ <script type="text/javascript" src="toc_conf.js"></script>
256
250
 
257
251
  <SCRIPT type="text/javascript" >
258
252
  <!--
@@ -1,6 +1,7 @@
1
1
  require 'pathname'
2
2
  # require 'FileUtils'
3
3
  require 'fileutils'
4
+ require 'os'
4
5
 
5
6
  class Tocmd::TranslatorLocal
6
7
  def initialize(source_file_path)
@@ -62,28 +63,22 @@ class Tocmd::TranslatorLocal
62
63
 
63
64
  def open_in_browser
64
65
  ar = @source_file_path.split('/')
66
+ src_path = ar.join('/').to_s
65
67
 
66
68
  if File.directory?(@source_file_path) == false #普通文件
67
- file_name = ar.pop().split('.')[0]
68
- src_path = ar.join('/').to_s
69
-
70
- ar.push('preview');
71
- dest_dir = ar.join('/').to_s
72
-
73
- `open #{ar.join('/').to_s}/#{file_name}.html`
74
-
69
+ file_name = ar.pop().split('.')[0]
75
70
  else
76
- # 目录
77
- src_path = ar.join('/').to_s
78
-
79
71
  Dir.foreach(src_path) do |ff|
80
72
  file_name = ff.split('.')[0]
81
73
  end
82
-
83
- ar.push('preview');
84
- dest_dir = ar.join('/').to_s
85
- `open #{ar.join('/').to_s}/#{file_name}.html`
86
74
  end
75
+
76
+ ar.push('preview');
77
+ dest_dir = ar.join('/').to_s
78
+ open_file_name = "#{ar.join('/').to_s}/#{file_name}.html"
79
+
80
+
81
+ OS.linux? ? `xdg-open #{ open_file_name }` : ` open #{ open_file_name }`
87
82
  end
88
83
 
89
84
  def generate_meta_js
data/lib/tocmd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tocmd
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/vendor/meta.js CHANGED
@@ -1 +1 @@
1
- /Users/shiren1118/Workspace/github/tocmd.gem/test_data/sample2.md
1
+ /Users/sang/workspace/github/tocmd.gem/test_data/sample2.md
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tocmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - shiren1118
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -87,7 +87,6 @@ files:
87
87
  - vendor/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css
88
88
  - vendor/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css
89
89
  - vendor/toc/style/makedownpad.css
90
- - vendor/toc/toc_conf.js
91
90
  homepage: http://ruby-china.org/topics/17028
92
91
  licenses: []
93
92
  metadata: {}
@@ -1,20 +0,0 @@
1
- var jquery_ztree_toc_opts = {
2
- debug:false,
3
- is_auto_number:true,
4
- documment_selector:'.markdown-body',
5
- ztreeStyle: {
6
- width:'326px',
7
- overflow: 'auto',
8
- position: 'fixed',
9
- 'z-index': 2147483647,
10
- border: '0px none',
11
- left: '0px',
12
- top: '0px',
13
- // 'overflow-x': 'hidden',
14
- 'height': $(window).height() + 'px'
15
- }
16
- }
17
- var markdown_panel_style = {
18
- 'width':'70%',
19
- 'margin-left':'25%'
20
- };