ace-helper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 000571508f883b1d18234ff9fc3bb00cf9a701e7
4
+ data.tar.gz: 410d58cee2abecc857df37d43e09d5314e9de866
5
+ SHA512:
6
+ metadata.gz: 70c27ef8727ce40c772214856f2ca5938b8fc34c82e957b7dfd3af34e12f2bb512af322ed2a47862a0b6065407d479732597bfcb77cb4da913e625a2f90a6be4
7
+ data.tar.gz: 04c9a81d7bb75c68b57132d135fc9a719791c8b09e2a69320956a0aa7e9ef037d56c6f5d1725d78574d44fe7cd760d6efb3dc4aa6f37c16454a44be3e87bc290
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ace-helper.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 cravista
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Ace::Helper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ace-helper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ace-helper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/ace-helper/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ace/helper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ace-helper"
8
+ spec.version = Ace::Helper::VERSION
9
+ spec.authors = ["jahpd"]
10
+ spec.email = ["gcravista@gmail.com"]
11
+ spec.summary = %q{Ace helper for Rails template views.}
12
+ spec.description = %q{It embeed basic code for embeed Ace-Editor into webpage or application.}
13
+ spec.homepage = "https://www.github.com/jahpd/ace-helper"
14
+ spec.license = "CC-BY-SA 3.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.3"
23
+
24
+ end
@@ -0,0 +1,70 @@
1
+ module Ace
2
+ module Helper
3
+ module Base
4
+
5
+ MODE = :coffee
6
+ THEME = :monokai
7
+
8
+ EDITOR = [
9
+ :ace,
10
+ "theme-#{THEME}",
11
+ "mode-#{MODE}",
12
+ "worker-#{MODE}"
13
+ ]
14
+
15
+ protected
16
+
17
+ #BASE_RUN = "gac.run (err, data) -> window.terminal.type(command+'\n') for command in [''+eval(data)+'
18
+ #BASE_CLEAR = "gac.clean (cleaned) -> if cleaned then window.terminal.type('# Audio cleaned')\n"
19
+
20
+ RENDER_OPTIONS = {
21
+ :lang => MODE, # The running-language of web-application
22
+ :theme => THEME#, # Initial theme to Ace editor
23
+ #:commands => { # Commands Of Ace editor, please use CoffeeScript syntax
24
+ # :render => {
25
+ # :bindKeys => "win: 'Ctrl-Enter', linux: 'Ctrl-Enter', mac: 'Command+,'",
26
+ # :exec => "(e) ->\n #{BASE_RUN}"
27
+ # },
28
+ # :stop => {
29
+ # :bindKeys => "win: 'Ctrl-.', linux: 'Ctrl-.', mac: 'Command-.'",
30
+ # :exec => "(e) -> #{BASE_CLEAR}"
31
+ # }
32
+ #}
33
+ }
34
+
35
+ COMMENT_MESSAGE = """# ======================================================================================
36
+ # Hi, this is an ace editor integrated with terminal
37
+ #
38
+ # All previous posts in index page
39
+ # show a way to use coffee-script language \/ \\
40
+ # See old ones if you do not know anything \/ \\
41
+ # \/_____\\
42
+ # You can use coffee-script here to change the code below \/ \\
43
+ # !Think in a way to make music! \/ \\
44
+ # When done, you can use hotkeys to render or stop music: ------------
45
+ # - Render audio: a A
46
+ # - Mac: Command + Enter aaa AAA
47
+ # - Linux / Windows: Ctrl + Enter aa aa------- AA AA
48
+ # - Stop audio: aa aa AA AA
49
+ # - Mac: Command + . aaa---aaa AAA---AAA
50
+ # - Linux / Window: Ctrl + . aa aa AA AA
51
+ # AA AA aa aa
52
+ # Or you can use 'render' or 'stop' commands AA AA aa aa
53
+ # with buttons above or type them in terminal aaaaaaaaaaaaaAAAAAAAAAAAAA
54
+ # at your right side. 0 .25 0.5 .75 1
55
+ # AAAAAAAAAAAAAaaaaaaaaaaaaa
56
+ # If you find any issue, please contact me in: aaaaaaaaaaaaaAAAAAAAAAAAAAAA
57
+ # https://github.com/jahpd/yaknowboutblogmusic/issues aaa aAA AAA
58
+ # aaaaa aaAAA AAAAA
59
+ # If you want to contribute with any code, fork it! aaaaaaa aaaAAAA AAAAAAA
60
+ #
61
+ # If you want to reply, some sugestion, critic
62
+ # send email for xxx@yyyy.zzz
63
+ # or join irc.freenode.net #labmacambira
64
+
65
+ # Happy live-coding!
66
+ # (DESTROY ME AND USE EDITOR!)
67
+ # ======================================================================================\n"""
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,56 @@
1
+ require "ace/helper/version"
2
+ require "ace/base"
3
+
4
+ module Ace
5
+ module Helper
6
+ module Builder
7
+
8
+ include Ace::Helper::Base
9
+ include ActionView::Helpers::JavaScriptHelper
10
+
11
+ # The javascript that runs:
12
+ # - Audio client based on gibberish.js
13
+ # - Ace editor with post code
14
+ def ace(code_string)
15
+ #string = hook_gac()
16
+ string = hook_editor(MODE, THEME)
17
+ string << hook_code(code_string)
18
+
19
+ # FIX
20
+ # When hook commands, the code do not appears on editor
21
+ # string << hook_ace_commands(RENDER_OPTIONS[:commands])
22
+ string = CoffeeScript.compile(string, :bare => true)
23
+ javascript_tag(string, :id => "ace-#{Time.now}")
24
+ end
25
+
26
+ protected
27
+
28
+ def hook_editor(mode, theme)
29
+ string = "window.editor = editor = ace.edit('#{mode}_editor')\n"
30
+ string << "editor.setTheme 'ace/theme/#{theme}'\n"
31
+ string << "editor.getSession().setMode 'ace/mode/#{mode}'\n"
32
+ string << "console.log 'Ace editor loaded!: {mode: #{mode}, theme: #{theme} }'\n"
33
+ end
34
+
35
+ def hook_code(code_string)
36
+ s = "#{COMMENT_MESSAGE}#{code_string}"
37
+ string = "editor.setValue '#{escape_javascript(s)}'\n"
38
+ string << "console.log 'code script embeeded to editor!'\n"
39
+ end
40
+
41
+ def hook_ace_commands(commands, offset)
42
+ src = ""
43
+ commands.each{|k, v|
44
+ src << "editor.commands.addCommand#{offset}"
45
+ src << "name: '#{k}'#{offset}"
46
+ v.each_pair{|kk, vv|
47
+ src << "#{kk}: #{vv}#{offset}"
48
+ }
49
+ src << "readOnly: true\n"
50
+ }
51
+ src << "console.log 'commands added to editor!'\n"
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ module Ace
2
+ module Helper
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ require "#{File.dirname(__FILE__)}/builder"
2
+
3
+ module Ace
4
+
5
+ module Helper
6
+
7
+ class Railtie < Rails::Railtie
8
+ initializer "ace.builder" do
9
+ ActionView::Base.send :include, Builder
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ace-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - jahpd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ description: It embeed basic code for embeed Ace-Editor into webpage or application.
42
+ email:
43
+ - gcravista@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - ace-helper.gemspec
54
+ - lib/ace/base.rb
55
+ - lib/ace/helper.rb
56
+ - lib/ace/helper/version.rb
57
+ - lib/ace/railtie.rb
58
+ homepage: https://www.github.com/jahpd/ace-helper
59
+ licenses:
60
+ - CC-BY-SA 3.0
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Ace helper for Rails template views.
82
+ test_files: []