mdv 0.1.0

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.
Files changed (5) hide show
  1. data/Changelog.md +3 -0
  2. data/LICENSE +21 -0
  3. data/README.md +17 -0
  4. data/bin/mdv +71 -0
  5. metadata +83 -0
@@ -0,0 +1,3 @@
1
+ ### 0.1.0 / 2012-08-24
2
+
3
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2012 Matijs van Zuijlen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -0,0 +1,17 @@
1
+ # MDV
2
+
3
+ Simple Markdown Viewer for GNOME 3.
4
+
5
+ ## Usage
6
+
7
+ mdv README.md
8
+
9
+ Press Ctrl-R to reload, Ctrl-Q to quit.
10
+
11
+ ## Install
12
+
13
+ gem install mdv
14
+
15
+ ## License
16
+
17
+ Copyright (c) 2012 Matijs van Zuijlen. See LICENSE for details.
data/bin/mdv ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gir_ffi-gtk3'
3
+ require 'github/markup'
4
+
5
+ GirFFI.setup :WebKit, '3.0'
6
+
7
+ Gtk.init
8
+
9
+ WebKit.set_cache_model :document_viewer
10
+
11
+ class MarkDownViewer
12
+ attr_reader :file
13
+
14
+ def initialize file
15
+ @file = file
16
+ setup_gui
17
+ reload
18
+ connect_signals
19
+ @win.show_all
20
+ end
21
+
22
+ def connect_signals
23
+ @win.signal_connect 'key-press-event' do |wdg, evt, ud|
24
+ if evt.state == :control_mask
25
+ case evt.keyval
26
+ when "q".ord
27
+ @win.destroy
28
+ when "r".ord
29
+ self.reload
30
+ end
31
+ end
32
+ false
33
+ end
34
+
35
+ @win.signal_connect("destroy") { Gtk.main_quit }
36
+ end
37
+
38
+ def setup_gui
39
+ @win = Gtk::Window.new :toplevel
40
+ @win.set_default_geometry 700, 500
41
+
42
+ @scr = Gtk::ScrolledWindow.new nil, nil
43
+ @wv = WebKit::WebView.new
44
+ @win.add @scr
45
+ @scr.add @wv
46
+ end
47
+
48
+ def fullpath
49
+ @fullpath ||= File.expand_path(file, Dir.pwd)
50
+ end
51
+
52
+ def base_uri
53
+ @base_uri ||= "file://#{fullpath}"
54
+ end
55
+
56
+ def html
57
+ GitHub::Markup.render(fullpath)
58
+ end
59
+
60
+ def reload
61
+ @wv.load_string html, nil, nil, base_uri
62
+ end
63
+ end
64
+
65
+ file = ARGV[0]
66
+ raise "Need file" unless file
67
+
68
+ MarkDownViewer.new file
69
+
70
+ Gtk.main
71
+
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mdv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matijs van Zuijlen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gir_ffi-gtk
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: github-markup
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.7.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.7.2
46
+ description: Quickly view markdown files on GNOME
47
+ email:
48
+ - matijs@matijs.net
49
+ executables:
50
+ - mdv
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - bin/mdv
55
+ - Changelog.md
56
+ - README.md
57
+ - LICENSE
58
+ homepage: http://www.github.com/mvz/mdv
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.23
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Simple Markdown Viewer
82
+ test_files: []
83
+ has_rdoc: