emacs_org_protocol_server 0.4.0 → 0.5.0
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/Rakefile +8 -0
- data/bin/console +6 -4
- data/emacs_org_protocol_server.gemspec +3 -0
- data/javascripts/bookmarklet.js +38 -0
- data/{shortkey.js → javascripts/shortkey.js} +0 -0
- data/lib/emacs_org_protocol_server.rb +13 -0
- data/lib/emacs_org_protocol_server/uglify.rb +34 -0
- data/lib/emacs_org_protocol_server/version.rb +1 -1
- metadata +46 -3
- data/bookmarklet.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27199ab432e45252ccda65a1bc2cab65addf2beb
|
4
|
+
data.tar.gz: 19d6821d5c598a3981e65b264095547befa9f611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf32c60135eb76c61cd2768d52b490931d907cabc8891c2f4215dd76bacc772d77e5843b48cdfc31e8a80b17dc682e2774e4b234776b26c169cbad00234b78f
|
7
|
+
data.tar.gz: d21f8afb8f2cf4700b94f34be8e213114a342ad8398f7a61df8dcbc8ba1badc90d5e0c6ecb59705a06ec7c7e0b7f1eaafbe7fbda2365b20249790887e17ccfee
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1 +1,9 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require 'emacs_org_protocol_server/uglify'
|
3
|
+
|
4
|
+
desc('Uglify the bookmarklet')
|
5
|
+
task(:uglify) do
|
6
|
+
input = File.join(File.dirname(__FILE__), 'javascripts', 'bookmarklet.js')
|
7
|
+
output = File.join(File.dirname(__FILE__), 'javascripts', 'bookmarklet.min.js')
|
8
|
+
EmacsOrgProtocolServer::Uglify.new(input, output).run!
|
9
|
+
end
|
data/bin/console
CHANGED
@@ -7,8 +7,10 @@ require "emacs_org_protocol_server"
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require "pry"
|
11
|
+
require 'pry-nav'
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
Pry.start
|
14
|
+
|
15
|
+
# require "irb"
|
16
|
+
# IRB.start
|
@@ -21,7 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "pry-byebug"
|
25
|
+
spec.add_development_dependency "pry-nav"
|
24
26
|
spec.add_dependency "thin"
|
25
27
|
spec.add_dependency "sinatra"
|
26
28
|
spec.add_dependency "sinatra-contrib"
|
29
|
+
spec.add_dependency "uglifier"
|
27
30
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
function fixEncoding(str) {
|
2
|
+
return encodeURIComponent(str)
|
3
|
+
.replace(/[!'()*]/g,
|
4
|
+
function(c) {
|
5
|
+
return '%' +
|
6
|
+
c.charCodeAt(0)
|
7
|
+
.toString(16);
|
8
|
+
}
|
9
|
+
);
|
10
|
+
}
|
11
|
+
|
12
|
+
var captureLink = function() {
|
13
|
+
var selection = window.getSelection().toString();
|
14
|
+
var location = window.location.href;
|
15
|
+
var title = document.title;
|
16
|
+
var description = document.querySelector('meta[name=description]');
|
17
|
+
var keywords = document.querySelector('meta[name=keywords]');
|
18
|
+
var protocol = 'capture';
|
19
|
+
|
20
|
+
if (description) {
|
21
|
+
description = description.attributes.content.value.toString()
|
22
|
+
}
|
23
|
+
|
24
|
+
if (keywords) {
|
25
|
+
keywords.attributes.content.value.toString()
|
26
|
+
}
|
27
|
+
|
28
|
+
var uri = 'http://localhost:9998/?' +
|
29
|
+
'p=' + protocol +
|
30
|
+
'&l=' + fixEncoding(location) +
|
31
|
+
'&t=' + fixEncoding(title) +
|
32
|
+
'&s=' + fixEncoding("description: " + description + "\n\n" + "selection: " + selection + "\n\n")
|
33
|
+
|
34
|
+
window.location = uri;
|
35
|
+
return uri;
|
36
|
+
};
|
37
|
+
|
38
|
+
captureLink();
|
File without changes
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "emacs_org_protocol_server/version"
|
2
|
+
require 'emacs_org_protocol_server/uglify'
|
2
3
|
require 'sinatra/base'
|
3
4
|
require 'uri'
|
4
5
|
require 'yaml'
|
@@ -62,6 +63,18 @@ module EmacsOrgProtocolServer
|
|
62
63
|
redirect to(params['l'])
|
63
64
|
end
|
64
65
|
|
66
|
+
get '/bookmarklet' do
|
67
|
+
bmraw = File.expand_path('../../javascripts/bookmarklet.js', __FILE__)
|
68
|
+
EmacsOrgProtocolServer::Uglify.new(bmraw).run!
|
69
|
+
end
|
70
|
+
|
71
|
+
get '/pwd' do
|
72
|
+
"current dir is #{Dir.pwd}"
|
73
|
+
end
|
74
|
+
|
75
|
+
get '/public' do
|
76
|
+
"contents of public folder: #{Dir['public/**/*'].join("\n")}"
|
77
|
+
end
|
65
78
|
end
|
66
79
|
|
67
80
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'uglifier'
|
2
|
+
|
3
|
+
class EmacsOrgProtocolServer::Uglify
|
4
|
+
|
5
|
+
DEFAULTS = {
|
6
|
+
output: {
|
7
|
+
preamble: 'javascript:'
|
8
|
+
},
|
9
|
+
mangle: {
|
10
|
+
toplevel: true
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
attr_accessor :input, :output, :options
|
15
|
+
|
16
|
+
def initialize(input, output=nil, options=nil)
|
17
|
+
self.input = input
|
18
|
+
self.output = output
|
19
|
+
self.options = DEFAULTS.merge(options || {})
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def run!
|
24
|
+
ugli = Uglifier.new(options).compile(File.read(input))
|
25
|
+
ugli.gsub!(/\n/,'')
|
26
|
+
if output
|
27
|
+
File.write(output, ugli)
|
28
|
+
else
|
29
|
+
ugli
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emacs_org_protocol_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tamara Temple
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-nav
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: thin
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +108,20 @@ dependencies:
|
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: uglifier
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
description: Simple Sinatra server to call org-protocol with emacsclient
|
84
126
|
email:
|
85
127
|
- tamouse@gmail.com
|
@@ -97,12 +139,13 @@ files:
|
|
97
139
|
- Rakefile
|
98
140
|
- bin/console
|
99
141
|
- bin/setup
|
100
|
-
- bookmarklet.js
|
101
142
|
- emacs_org_protocol_server.gemspec
|
102
143
|
- exe/emacs_org_protocol_server
|
144
|
+
- javascripts/bookmarklet.js
|
145
|
+
- javascripts/shortkey.js
|
103
146
|
- lib/emacs_org_protocol_server.rb
|
147
|
+
- lib/emacs_org_protocol_server/uglify.rb
|
104
148
|
- lib/emacs_org_protocol_server/version.rb
|
105
|
-
- shortkey.js
|
106
149
|
homepage: https://github.com/tamouse/emacs_org_protocol_server
|
107
150
|
licenses:
|
108
151
|
- MIT
|
data/bookmarklet.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
javascript:function fx(str){return encodeURIComponent(str).replace(/[!'()*]/g, function(c){return '%' + c.charCodeAt(0).toString(16);});};var captureLink=function(){var s=window.getSelection().toString(),l=window.location.href,t=document.title, d=document.querySelector('meta[name=description]'), k=document.querySelector('meta[name=keywords]'),p='capture';if(d){d=d.attributes.content.value.toString()};if(k){k.attributes.content.value.toString()};var uri='http://localhost:9998/?'+'p='+p+'&l='+fx(l)+'&t='+fx(t)+'&s='+fx("description: "+d+"\n\n" + "selection: " + s + "\n\n");window.location=uri;return uri;};captureLink();
|