glim-edit-in-textmate 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/glim-edit-in-textmate.rb +39 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ed1e86ebd1033ae15a8c0777aa19a6c2e9a5470c1e26ccc0b95b0a14367bdae
|
4
|
+
data.tar.gz: 20fcd7939c902cd00ef398f2a7c2d13753979253c9fb860b5aee66e818ce7e2b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5b937839c1c588a5156571ff507761bdbcada30278687a44820efea39c6b9c39e93f188929e0cd7d3a3c6457c475b552ff40e23a561bdd3966db9625e8129dc
|
7
|
+
data.tar.gz: 542cafbd1bd8b9931d5ccadf993097110aeb4f77730a31d168fa3ae4354cb87785d5e1f6ad4409ae9b57d8dbe19b4083aa723a2590d923f89628f134f2bc5101
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module GlimExtensions
|
4
|
+
class EditInTextMate < Glim::Filter
|
5
|
+
transforms 'output.html' => 'output.html'
|
6
|
+
|
7
|
+
def initialize(site)
|
8
|
+
@enabled = site.config['environment'] == 'development'
|
9
|
+
end
|
10
|
+
|
11
|
+
def transform(content, page, options)
|
12
|
+
if @enabled && page.path
|
13
|
+
script_tag = edit_in_textmate_script(page.path)
|
14
|
+
if content =~ /<head.*?>/
|
15
|
+
content = "#$`#$&#{script_tag}#$'"
|
16
|
+
elsif content =~ /<html.*?>/
|
17
|
+
content = "#$`#$&#{script_tag}#$'"
|
18
|
+
else
|
19
|
+
content = script_tag + content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
content
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit_in_textmate_script(path)
|
26
|
+
<<~HTML
|
27
|
+
<script>
|
28
|
+
window.onkeydown = function (e) {
|
29
|
+
if(!document.activeElement || document.activeElement == document.body) {
|
30
|
+
if(e.key == 'e' && !(e.altKey || e.shiftKey || e.ctrlKey || e.metaKey)) {
|
31
|
+
window.location = "txmt://open?url=#{CGI.escape('file://' + path)}";
|
32
|
+
}
|
33
|
+
}
|
34
|
+
};
|
35
|
+
</script>
|
36
|
+
HTML
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glim-edit-in-textmate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Allan Odgaard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: glim
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- glim-edit-in-textmate.rb
|
34
|
+
homepage: https://macromates.com/glim/
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- "."
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.7.6
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Press E in your browser to edit the page in TextMate.
|
58
|
+
test_files: []
|