mdv 0.3.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d8ae58018911dd37af67935880a3a18abbb7ffc4
4
- data.tar.gz: ddfab34f27ce6af584c4990a06f51e0888906317
2
+ SHA256:
3
+ metadata.gz: ddd8a0a7b01d6bda74b737a721de8c669ae9e0c98b3013de38eeadf1a5e7f218
4
+ data.tar.gz: a235ba63ea1d337f543ebe72676104c31ad06949ec73a7a54f73647cfd498aec
5
5
  SHA512:
6
- metadata.gz: 07b27b674063ce928eceedac586b67c278f4d1ae2f1a937a79490a3e6322fc89f44626c589afb36d76f2212ff98430ff0905608f08c8eaf5c080b58db3fa7a65
7
- data.tar.gz: 8e0ca22c3025613ec2e9baf39ef503a0c02cda169541e095a94c544bb7166e1694ec23304dfd21bdabeda1dcfb590b07650a77e1bba1b2160c3c1e79b0bd3756
6
+ metadata.gz: c74b43702a9884a5ed3cb9d96b40b70c4ddcb32961e47cf0e69cd72e7bf0275605ccbd94648869cbe4d44527d8db4e2bdc6a0313a4bd1fd8acb155c43ba81a94
7
+ data.tar.gz: 64e4fb4e4abe3b02cd4f51ec7599cd6d3e5401546821d087430a78bf618ece8fea216a7504f75c70314778201ed6d38cef8032bae9a1250578d63c0986b03f43
@@ -1,8 +1,15 @@
1
1
  # Change log
2
2
 
3
+ ## 0.4.0 / 2018-09-12
4
+
5
+ * Drop support for Ruby 2.2 and lower
6
+ * Update dependencies
7
+ * Hide context menus to prevent unwanted actions
8
+ * Open links in default browser instead of in mdv itself
9
+
3
10
  ## 0.3.1 / 2017-11-11
4
11
 
5
- * Port to Ruby-GNOME2
12
+ * Update dependencies
6
13
 
7
14
  ## 0.3.0 / 2017-04-25
8
15
 
@@ -24,7 +31,7 @@
24
31
 
25
32
  * Update dependency on GirFFI
26
33
  * Update code to use GirFFI's new bitmasks
27
- * Use updated atspi_app_driver to fix tests
34
+ * Use updated `atspi_app_driver` to fix tests
28
35
 
29
36
  ## 0.1.6 / 2015-10-17
30
37
 
@@ -35,7 +42,7 @@
35
42
 
36
43
  * Ensure all relevant files are released in the gem
37
44
  * Code restructuring
38
- * Tested end-to-end using atspi_app_driver
45
+ * Tested end-to-end using `atspi_app_driver`
39
46
  * Updated dependencies
40
47
 
41
48
  ## 0.1.4 / 2014-05-27
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -6,7 +6,8 @@ Simple Markdown Viewer for GNOME 3.
6
6
 
7
7
  mdv README.md
8
8
 
9
- Press Ctrl-R to reload, Ctrl-Q to quit.
9
+ Press Ctrl-R to reload, Ctrl-Q to quit, Ctrl-C to copy selected text. Clicked
10
+ links open in default browser.
10
11
 
11
12
  ## Install
12
13
 
@@ -14,30 +15,14 @@ Press Ctrl-R to reload, Ctrl-Q to quit.
14
15
 
15
16
  ## Dependencies
16
17
 
17
- MDV needs some additional software installed in order to work.
18
-
19
- ### Debian
20
-
21
- The following should work:
22
-
23
- sudo apt-get install libgirepository1.0-dev gobject-introspection
24
- sudo apt-get install libwebkit2gtk-4.0-dev
25
-
26
- ### Other OS
27
-
28
- To be determined. Please contribute back your experience in getting MDV running
29
- on your favorite operation system.
18
+ MDV depends on the wekit2-gtk gem.
30
19
 
31
20
  ## Contributing
32
21
 
33
22
  Contributions are welcome! Please feel free to create issues or pull requests
34
23
  on GitHub.
35
24
 
36
- If you want to run the tests, you may need to install additional packages:
37
-
38
- sudo apt-get install gir1.2-atspi-2.0 libatk-adaptor
39
-
40
25
  ## License
41
26
 
42
- Copyright © 2012–2016 [Matijs van Zuijlen](http://www.matijs.net).
27
+ Copyright © 2012–2018 [Matijs van Zuijlen](http://www.matijs.net).
43
28
  See LICENSE for details.
data/Rakefile CHANGED
@@ -1,15 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/clean'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'rake/testtask'
4
6
 
5
7
  namespace :test do
8
+ Rake::TestTask.new(:unit) do |t|
9
+ t.libs = ['lib']
10
+ t.test_files = FileList['test/mdv/*_test.rb']
11
+ t.warning = true
12
+ end
13
+
6
14
  Rake::TestTask.new(:end_to_end) do |t|
7
15
  t.libs = ['lib']
8
16
  t.test_files = FileList['test/end_to_end/*_test.rb']
9
17
  t.warning = true
10
18
  end
11
19
 
12
- task all: [:end_to_end]
20
+ task all: [:unit, :end_to_end]
13
21
  end
14
22
 
15
23
  task test: 'test:all'
data/bin/mdv CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require 'github/markup'
2
+ # frozen_string_literal: true
3
+
3
4
  require 'mdv'
4
5
 
5
6
  Gtk.init
data/lib/mdv.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'mdv/markdown_viewer'
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'github/markup'
4
+
5
+ module MDV
6
+ # Markdown document class
7
+ class Document
8
+ def initialize(file)
9
+ @file = file
10
+ end
11
+
12
+ def base_uri
13
+ @base_uri ||= "file://#{fullpath}"
14
+ end
15
+
16
+ def html
17
+ GitHub::Markup.render(fullpath, File.read(fullpath))
18
+ end
19
+
20
+ private
21
+
22
+ def fullpath
23
+ @fullpath ||= File.expand_path(@file, Dir.pwd)
24
+ end
25
+ end
26
+ end
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'webkit2-gtk'
4
+ require 'mdv/document'
2
5
 
3
6
  module MDV
4
7
  # Markdown viewer window class
5
8
  class MarkdownViewer
6
- attr_reader :file
7
-
8
9
  def initialize(file)
9
- @file = file
10
+ @document = Document.new(file)
10
11
  setup_gui
11
12
  reload
12
13
  connect_signals
@@ -18,6 +19,7 @@ module MDV
18
19
  def connect_signals
19
20
  connect_key_press_event_signal
20
21
  connect_destroy_signal
22
+ connect_web_view_signals
21
23
  end
22
24
 
23
25
  def connect_destroy_signal
@@ -31,6 +33,13 @@ module MDV
31
33
  end
32
34
  end
33
35
 
36
+ def connect_web_view_signals
37
+ web_view.signal_connect('context-menu') { true }
38
+ web_view.signal_connect('decide-policy') do |_wv, decision, decision_type|
39
+ handle_decide_policy(decision, decision_type)
40
+ end
41
+ end
42
+
34
43
  def handle_key(evt)
35
44
  case evt.keyval
36
45
  when 'q'.ord
@@ -40,6 +49,19 @@ module MDV
40
49
  end
41
50
  end
42
51
 
52
+ def handle_decide_policy(decision, decision_type)
53
+ case decision_type.nick
54
+ when 'navigation-action'
55
+ action = decision.navigation_action
56
+ if action.user_gesture?
57
+ Gtk.show_uri_on_window(@win, action.request.uri, 0)
58
+ true
59
+ end
60
+ when 'new-window-action'
61
+ true
62
+ end
63
+ end
64
+
43
65
  def setup_gui
44
66
  @win = Gtk::Window.new :toplevel
45
67
  @win.set_default_geometry 700, 500
@@ -48,29 +70,17 @@ module MDV
48
70
  end
49
71
 
50
72
  def scrolled_window
51
- @scr ||= Gtk::ScrolledWindow.new(nil, nil).tap do |it|
73
+ @scrolled_window ||= Gtk::ScrolledWindow.new(nil, nil).tap do |it|
52
74
  it.add web_view
53
75
  end
54
76
  end
55
77
 
56
78
  def web_view
57
- @wv ||= WebKit2Gtk::WebView.new
58
- end
59
-
60
- def fullpath
61
- @fullpath ||= File.expand_path(file, Dir.pwd)
62
- end
63
-
64
- def base_uri
65
- @base_uri ||= "file://#{fullpath}"
66
- end
67
-
68
- def html
69
- GitHub::Markup.render(fullpath)
79
+ @web_view ||= WebKit2Gtk::WebView.new
70
80
  end
71
81
 
72
82
  def reload
73
- web_view.load_html html, base_uri
83
+ web_view.load_html @document.html, @document.base_uri
74
84
  end
75
85
  end
76
86
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../test_helper'
2
4
  require 'gnome_app_driver'
3
5
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ require 'mdv/document'
6
+
7
+ describe MDV::Document do
8
+ let(:document) { MDV::Document.new('test/fixtures/test.md') }
9
+
10
+ describe '#html' do
11
+ it 'renders the correct html' do
12
+ document.html.
13
+ must_equal "<h1>Test</h1>\n\n<p>This is a test document.</p>\n"
14
+ end
15
+ end
16
+ end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-11 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-markdown
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webkit2-gtk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -109,8 +109,10 @@ files:
109
109
  - Rakefile
110
110
  - bin/mdv
111
111
  - lib/mdv.rb
112
+ - lib/mdv/document.rb
112
113
  - lib/mdv/markdown_viewer.rb
113
114
  - test/end_to_end/basic_run_test.rb
115
+ - test/mdv/document_test.rb
114
116
  - test/test_helper.rb
115
117
  homepage: http://www.github.com/mvz/mdv
116
118
  licenses:
@@ -124,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
126
  requirements:
125
127
  - - ">="
126
128
  - !ruby/object:Gem::Version
127
- version: '0'
129
+ version: 2.3.0
128
130
  required_rubygems_version: !ruby/object:Gem::Requirement
129
131
  requirements:
130
132
  - - ">="
@@ -132,10 +134,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
134
  version: '0'
133
135
  requirements: []
134
136
  rubyforge_project:
135
- rubygems_version: 2.6.13
137
+ rubygems_version: 2.7.6
136
138
  signing_key:
137
139
  specification_version: 4
138
140
  summary: Simple Markdown Viewer
139
141
  test_files:
142
+ - test/mdv/document_test.rb
140
143
  - test/test_helper.rb
141
144
  - test/end_to_end/basic_run_test.rb