github-markdown-server 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +10 -1
- data/Rakefile +10 -0
- data/bin/github-markdown-server +0 -1
- data/contrib/github-markdown-server.el +17 -9
- data/lib/github-markdown-server/server.rb +2 -2
- data/lib/github-markdown-server/version.rb +1 -1
- data/test/github-markdown-server_test.rb +19 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6698f6b08e38b1fdb375313348dfc3992b5c5f41
|
4
|
+
data.tar.gz: 1068e064418e8b05d1f0b336ac19e87fe6d4fd49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e38cfdccdf8507e7d9cf092627b8bb56f95ee53918b9608fa368aa55f453e872d9eb4bb7eb7cdcbdef9bd694fe5e06cc1645c29f8ca987d631185cdbbf7c48
|
7
|
+
data.tar.gz: 7895ab83a06b42785c6f1a8bb2e6ba1f237baab5440c5551128f86563765886c18565007a2d39ea357bbb88956ec7ad1df18b25a4d4d9b4093048a5d1272ba75
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -3,7 +3,16 @@
|
|
3
3
|
Use your favorite editor to edit a markdown file, Run the server and open the file.
|
4
4
|
Saving in your editor updates instantly in the browser.
|
5
5
|
|
6
|
-
github-markdown-server is built on top of [github-markdown-preview](https://github.com/dmarcotte/github-markdown-preview).
|
6
|
+
github-markdown-server is built on top of [github-markdown-preview](https://github.com/dmarcotte/github-markdown-preview) and [live.js](http://www.livejs.com/).
|
7
|
+
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/github-markdown-server.svg)](http://badge.fury.io/rb/github-markdown-server)
|
9
|
+
[![Build Status](https://travis-ci.org/arkarkark/github-markdown-server.svg)](https://travis-ci.org/arkarkark/github-markdown-server)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```shell
|
14
|
+
gem install github-markdown-server
|
15
|
+
```
|
7
16
|
|
8
17
|
## Usage
|
9
18
|
|
data/Rakefile
ADDED
data/bin/github-markdown-server
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
(defvar github-markdown-servers '() "The servers we have running.")
|
11
11
|
(defvar github-markdown-server-port 7494 "The next available server port.")
|
12
|
-
(defvar github-markdown-server-browser "Google Chrome" "Application to use with osx's open -a to open files.")
|
13
12
|
|
14
13
|
(defun git-base (&optional file-name)
|
15
14
|
"Get the base of a git repository for FILE-NAME (or the current buffer)."
|
@@ -54,8 +53,8 @@
|
|
54
53
|
(concat "lsof -n -i4TCP:" (number-to-string github-markdown-server-port) " | grep LISTEN"))))
|
55
54
|
(setq github-markdown-server-port (+ github-markdown-server-port 1)))
|
56
55
|
|
57
|
-
(
|
58
|
-
(
|
56
|
+
(setq server (cons base github-markdown-server-port)))
|
57
|
+
(message (concat "starting github-markdown-server on port:" (number-to-string (cdr server)))))
|
59
58
|
(call-process-shell-command
|
60
59
|
(concat "github-markdown-server"
|
61
60
|
" --directory=" (shell-quote-argument (car server))
|
@@ -71,22 +70,31 @@
|
|
71
70
|
(defun view-file-in-browser (&optional file-name)
|
72
71
|
"Open up file on github or via a local markdown server.
|
73
72
|
FILE-NAME will be current buffer if not specified.
|
74
|
-
Prefix arg \[universal-argument] to not run local server."
|
73
|
+
Prefix arg \[universal-argument] to not run local server for markdown files."
|
75
74
|
(interactive (list (buffer-file-name)))
|
76
75
|
(if (and (not current-prefix-arg) (string-match "\.md$" file-name))
|
77
76
|
(github-markdown-serve file-name)
|
78
77
|
(call-process-shell-command
|
79
|
-
|
78
|
+
;; open it with the default webbrowser The Mac::InternetConfig stuff)
|
79
|
+
;; open either on github or a local file (the remove.origin.url stuff)
|
80
|
+
(concat "open -a \"$(VERSIONER_PERL_PREFER_32_BIT=1 "
|
81
|
+
"perl -MMac::InternetConfig -le 'print +(GetICHelper \"http\")[1]')\" \"$("
|
80
82
|
"perl -e 'use File::Basename; $f = shift @ARGV; $d = dirname($f); $b = basename($f); "
|
81
83
|
"$o = `git -C $d config --get remote.origin.url`; "
|
82
|
-
"if ($o =~ qr
|
84
|
+
"if ($o =~ qr!git(@|://)github.com[:/]!) { "
|
83
85
|
" $o =~ s!git(@|://)github.com[:/](.*).git$!https://github.com/$2!; "
|
84
86
|
"} else { $o = \"\" }"
|
85
87
|
"$p = `git -C $d rev-parse --show-prefix`; "
|
86
88
|
"chomp($o, $p); "
|
87
|
-
"if ($o) { print \"$o/blob/master/$p$b\
|
88
|
-
(shell-quote-argument (buffer-file-name)) ")
|
89
|
-
|
89
|
+
"if ($o) { print \"$o/blob/master/$p$b\"; } else { print \"file://$f\" }' "
|
90
|
+
(shell-quote-argument (buffer-file-name)) ")#L"
|
91
|
+
(if (region-active-p)
|
92
|
+
(concat
|
93
|
+
(number-to-string (line-number-at-pos (region-beginning))) "-"
|
94
|
+
(number-to-string (line-number-at-pos (region-end))))
|
95
|
+
(number-to-string (line-number-at-pos)))
|
96
|
+
"\"")
|
97
|
+
nil 0)))
|
90
98
|
|
91
99
|
(provide 'github-markdown-server)
|
92
100
|
;;; github-markdown-server ends here
|
@@ -16,10 +16,10 @@ module GithubMarkdownServer
|
|
16
16
|
url = "http://localhost:#{port}/"
|
17
17
|
|
18
18
|
if !File.directory?(@directory)
|
19
|
-
@directory = File.dirname(@
|
19
|
+
@directory = File.dirname(@file_name)
|
20
20
|
end
|
21
21
|
|
22
|
-
url
|
22
|
+
url = url + @file_name[@directory.length + 1..-1] if @file_name != @directory
|
23
23
|
|
24
24
|
server_options = {
|
25
25
|
:Port => port,
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
class TestBin < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@gms_scipt = File.join(File.dirname(__FILE__), '..', 'bin', 'github-markdown-server')
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_bad_params
|
9
|
+
IO.popen("bundle exec #{@gms_scipt} --nonsense") do |io|
|
10
|
+
assert_match(/.*invalid option: --nonsense.*/, io.read, 'invalid option: --nonsense')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_version_ouput
|
15
|
+
IO.popen("bundle exec #{@gms_scipt} -v") do |io|
|
16
|
+
assert_match(GithubMarkdownServer::VERSION, io.read, '-v call should output version')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-markdown-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex K (wtwf.com)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-markdown-preview
|
@@ -80,8 +80,11 @@ extensions: []
|
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
82
|
- ".gitignore"
|
83
|
+
- ".travis.yml"
|
84
|
+
- Gemfile
|
83
85
|
- LICENSE
|
84
86
|
- README.md
|
87
|
+
- Rakefile
|
85
88
|
- bin/github-markdown-server
|
86
89
|
- contrib/github-markdown-server.el
|
87
90
|
- data/image/favicon.ico
|
@@ -91,6 +94,7 @@ files:
|
|
91
94
|
- lib/github-markdown-server/resources.rb
|
92
95
|
- lib/github-markdown-server/server.rb
|
93
96
|
- lib/github-markdown-server/version.rb
|
97
|
+
- test/github-markdown-server_test.rb
|
94
98
|
homepage: https://github.com/arkarkark/github-markdown-server
|
95
99
|
licenses:
|
96
100
|
- MIT
|
@@ -116,4 +120,5 @@ signing_key:
|
|
116
120
|
specification_version: 4
|
117
121
|
summary: Use your favorite editor to edit a markdown file, Run the server and open
|
118
122
|
the file. Saving in your editor updates instantly in the browser.
|
119
|
-
test_files:
|
123
|
+
test_files:
|
124
|
+
- test/github-markdown-server_test.rb
|