diamonds 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/lib/diamonds.rb +74 -0
- data/lib/diamonds/Gemfile +28 -0
- data/lib/diamonds/README.md +254 -0
- data/lib/diamonds/Rakefile +5 -0
- data/lib/diamonds/apps/application.rb +15 -0
- data/lib/diamonds/apps/library.rb +321 -0
- data/lib/diamonds/apps/user_app.rb +5 -0
- data/lib/diamonds/config.ru +98 -0
- data/lib/diamonds/db/mysiteDB Back.sqlite3 +0 -0
- data/lib/diamonds/db/mysiteDB.sqlite3 +0 -0
- data/lib/diamonds/gems/auto_launch_browser.rb +22 -0
- data/lib/diamonds/gems/io.rb +146 -0
- data/lib/diamonds/gems/ruby_to_js.rb +173 -0
- data/lib/diamonds/gems/server_utils.rb +96 -0
- data/lib/diamonds/lib/opal-browser.rb +1 -0
- data/lib/diamonds/lib/opal/browser.rb +4 -0
- data/lib/diamonds/opal-browser.gemspec +21 -0
- data/lib/diamonds/opal/browser.rb +11 -0
- data/lib/diamonds/opal/browser/animation_frame.rb +111 -0
- data/lib/diamonds/opal/browser/canvas.rb +321 -0
- data/lib/diamonds/opal/browser/canvas/data.rb +63 -0
- data/lib/diamonds/opal/browser/canvas/gradient.rb +27 -0
- data/lib/diamonds/opal/browser/canvas/style.rb +113 -0
- data/lib/diamonds/opal/browser/canvas/text.rb +45 -0
- data/lib/diamonds/opal/browser/console.rb +103 -0
- data/lib/diamonds/opal/browser/cookies.rb +133 -0
- data/lib/diamonds/opal/browser/css.rb +24 -0
- data/lib/diamonds/opal/browser/css/declaration.rb +83 -0
- data/lib/diamonds/opal/browser/css/rule.rb +48 -0
- data/lib/diamonds/opal/browser/css/rule/style.rb +16 -0
- data/lib/diamonds/opal/browser/css/style_sheet.rb +83 -0
- data/lib/diamonds/opal/browser/css/unit.rb +188 -0
- data/lib/diamonds/opal/browser/database/sql.rb +194 -0
- data/lib/diamonds/opal/browser/delay.rb +78 -0
- data/lib/diamonds/opal/browser/dom.rb +84 -0
- data/lib/diamonds/opal/browser/dom/attribute.rb +26 -0
- data/lib/diamonds/opal/browser/dom/builder.rb +88 -0
- data/lib/diamonds/opal/browser/dom/cdata.rb +9 -0
- data/lib/diamonds/opal/browser/dom/character_data.rb +73 -0
- data/lib/diamonds/opal/browser/dom/comment.rb +9 -0
- data/lib/diamonds/opal/browser/dom/document.rb +149 -0
- data/lib/diamonds/opal/browser/dom/document_fragment.rb +7 -0
- data/lib/diamonds/opal/browser/dom/element.rb +474 -0
- data/lib/diamonds/opal/browser/dom/element/attributes.rb +87 -0
- data/lib/diamonds/opal/browser/dom/element/data.rb +67 -0
- data/lib/diamonds/opal/browser/dom/element/image.rb +23 -0
- data/lib/diamonds/opal/browser/dom/element/input.rb +28 -0
- data/lib/diamonds/opal/browser/dom/element/offset.rb +89 -0
- data/lib/diamonds/opal/browser/dom/element/position.rb +46 -0
- data/lib/diamonds/opal/browser/dom/element/scroll.rb +136 -0
- data/lib/diamonds/opal/browser/dom/element/select.rb +36 -0
- data/lib/diamonds/opal/browser/dom/element/size.rb +34 -0
- data/lib/diamonds/opal/browser/dom/element/template.rb +9 -0
- data/lib/diamonds/opal/browser/dom/element/textarea.rb +24 -0
- data/lib/diamonds/opal/browser/dom/mutation_observer.rb +178 -0
- data/lib/diamonds/opal/browser/dom/node.rb +464 -0
- data/lib/diamonds/opal/browser/dom/node_set.rb +110 -0
- data/lib/diamonds/opal/browser/dom/text.rb +36 -0
- data/lib/diamonds/opal/browser/effects.rb +50 -0
- data/lib/diamonds/opal/browser/event.rb +253 -0
- data/lib/diamonds/opal/browser/event/animation.rb +38 -0
- data/lib/diamonds/opal/browser/event/audio_processing.rb +33 -0
- data/lib/diamonds/opal/browser/event/base.rb +430 -0
- data/lib/diamonds/opal/browser/event/before_unload.rb +15 -0
- data/lib/diamonds/opal/browser/event/clipboard.rb +28 -0
- data/lib/diamonds/opal/browser/event/close.rb +47 -0
- data/lib/diamonds/opal/browser/event/composition.rb +50 -0
- data/lib/diamonds/opal/browser/event/custom.rb +65 -0
- data/lib/diamonds/opal/browser/event/device_light.rb +23 -0
- data/lib/diamonds/opal/browser/event/device_motion.rb +51 -0
- data/lib/diamonds/opal/browser/event/device_orientation.rb +48 -0
- data/lib/diamonds/opal/browser/event/device_proximity.rb +33 -0
- data/lib/diamonds/opal/browser/event/drag.rb +119 -0
- data/lib/diamonds/opal/browser/event/focus.rb +39 -0
- data/lib/diamonds/opal/browser/event/gamepad.rb +60 -0
- data/lib/diamonds/opal/browser/event/hash_change.rb +28 -0
- data/lib/diamonds/opal/browser/event/keyboard.rb +115 -0
- data/lib/diamonds/opal/browser/event/message.rb +70 -0
- data/lib/diamonds/opal/browser/event/mouse.rb +254 -0
- data/lib/diamonds/opal/browser/event/page_transition.rb +23 -0
- data/lib/diamonds/opal/browser/event/pop_state.rb +33 -0
- data/lib/diamonds/opal/browser/event/progress.rb +43 -0
- data/lib/diamonds/opal/browser/event/sensor.rb +15 -0
- data/lib/diamonds/opal/browser/event/storage.rb +43 -0
- data/lib/diamonds/opal/browser/event/touch.rb +60 -0
- data/lib/diamonds/opal/browser/event/ui.rb +38 -0
- data/lib/diamonds/opal/browser/event/wheel.rb +49 -0
- data/lib/diamonds/opal/browser/event_source.rb +70 -0
- data/lib/diamonds/opal/browser/history.rb +90 -0
- data/lib/diamonds/opal/browser/http.rb +169 -0
- data/lib/diamonds/opal/browser/http/binary.rb +58 -0
- data/lib/diamonds/opal/browser/http/headers.rb +109 -0
- data/lib/diamonds/opal/browser/http/request.rb +344 -0
- data/lib/diamonds/opal/browser/http/response.rb +115 -0
- data/lib/diamonds/opal/browser/immediate.rb +163 -0
- data/lib/diamonds/opal/browser/interval.rb +111 -0
- data/lib/diamonds/opal/browser/location.rb +87 -0
- data/lib/diamonds/opal/browser/navigator.rb +173 -0
- data/lib/diamonds/opal/browser/screen.rb +66 -0
- data/lib/diamonds/opal/browser/socket.rb +123 -0
- data/lib/diamonds/opal/browser/storage.rb +252 -0
- data/lib/diamonds/opal/browser/support.rb +287 -0
- data/lib/diamonds/opal/browser/utils.rb +74 -0
- data/lib/diamonds/opal/browser/version.rb +3 -0
- data/lib/diamonds/opal/browser/window.rb +120 -0
- data/lib/diamonds/opal/browser/window/scroll.rb +59 -0
- data/lib/diamonds/opal/browser/window/size.rb +59 -0
- data/lib/diamonds/opal/browser/window/view.rb +36 -0
- data/lib/diamonds/opal/opal-browser.rb +1 -0
- data/lib/diamonds/public/__OPAL_SOURCE_MAPS__/application.map +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/HELP-US-OUT.txt +7 -0
- data/lib/diamonds/public/javascripts/font-awesome/css/font-awesome.css +2026 -0
- data/lib/diamonds/public/javascripts/font-awesome/css/font-awesome.min.css +1 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/FontAwesome.otf +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.svg +640 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/animated.less +34 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/bordered-pulled.less +25 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/core.less +12 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/fixed-width.less +6 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/font-awesome.less +17 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/icons.less +677 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/larger.less +13 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/list.less +19 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/mixins.less +26 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/path.less +15 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/rotated-flipped.less +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/stacked.less +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/variables.less +688 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_animated.scss +34 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_bordered-pulled.scss +25 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_core.scss +12 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_fixed-width.scss +6 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_icons.scss +677 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_larger.scss +13 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_list.scss +19 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_mixins.scss +26 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_path.scss +15 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_rotated-flipped.scss +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_stacked.scss +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_variables.scss +688 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/font-awesome.scss +17 -0
- data/lib/diamonds/public/javascripts/jquery-2.1.4.min.js +4 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_228ef1_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.min.css +7 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.min.js +13 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.structure.min.css +5 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.theme.min.css +5 -0
- data/lib/diamonds/public/javascripts/jquery.js +4 -0
- data/lib/diamonds/public/javascripts/jquery.ui.touch-punch.min.js +11 -0
- data/lib/diamonds/public/javascripts/ne pas utiliser version en retard jeezs_editor.js b/data/lib/diamonds/public/javascripts/ne pas utiliser version en retard → jeezs_editor.js +0 -0
- data/lib/diamonds/public/javascripts/standalone.js +2316 -0
- data/lib/diamonds/public/javascripts/standalone.min.js +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg-editor.min.css +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg-editor.min.js +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg.min.js +1 -0
- data/lib/diamonds/user_app/main.rb +45 -0
- data/lib/diamonds/version.rb +3 -0
- data/lib/diamonds/views/index.erb +35 -0
- data/lib/diamonds/views/javascripts/jeezs_editor.js.erb +365 -0
- data/lib/diamonds/views/stylesheets/main.css.erb +244 -0
- metadata +490 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3980bd9da584141dd37ed671b56aa860eaea68f4
|
4
|
+
data.tar.gz: 9d09be85e5596bf32f8bfdf2b0c2a23fea358fa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: daa8ec8e683faec7a90e857879a0ca8fa037dd949690e63ec8249c56901d7ffa5ef661621b84b9b7de2924bf5a621e7bfe1a8f47e0ab6b2203d66d8d67dab20b
|
7
|
+
data.tar.gz: 080db7948ae41f65a0975044c3f6e1eb2d32186c8144785b22b465c145a5043b081772b8cea72c6b71418f3df51be39e9fb1ca8f42c9e8f12df2c8566d53a09b
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Diamonds
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/diamonds`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'diamonds'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install diamonds
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/diamonds.
|
36
|
+
|
data/lib/diamonds.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "diamonds/version"
|
2
|
+
require "fileutils"
|
3
|
+
module Diamonds
|
4
|
+
this_file_is_call_by=$0
|
5
|
+
folder_caller_file=File.dirname(this_file_is_call_by)
|
6
|
+
current_file=__FILE__
|
7
|
+
current_folder=File.dirname(current_file)
|
8
|
+
|
9
|
+
file_to_save=""
|
10
|
+
File.open(this_file_is_call_by).each do |line|
|
11
|
+
|
12
|
+
if (line.include? "require")
|
13
|
+
|
14
|
+
if (line.include? "diamonds")
|
15
|
+
#We do not copy the line
|
16
|
+
else
|
17
|
+
|
18
|
+
if (line.include? "/")
|
19
|
+
#it's a local gem require we copy the file and keep the require
|
20
|
+
|
21
|
+
line= line.gsub("require","").gsub("'","").gsub('"',"").gsub("\n","").lstrip
|
22
|
+
filename=line.sub("./","/")
|
23
|
+
filename=folder_caller_file+filename
|
24
|
+
|
25
|
+
filename= filename+".rb"
|
26
|
+
|
27
|
+
filecontent=File.read(filename)
|
28
|
+
|
29
|
+
|
30
|
+
line=line.sub("./","/")
|
31
|
+
newfilename=current_folder+"/diamonds/user_app"+line+".rb"
|
32
|
+
line='require "./user_app'+line+'"'
|
33
|
+
|
34
|
+
|
35
|
+
dir_found= newfilename.split("/")
|
36
|
+
dir_found.pop
|
37
|
+
|
38
|
+
dir_found=dir_found.join("/")
|
39
|
+
|
40
|
+
FileUtils::mkdir_p dir_found
|
41
|
+
|
42
|
+
File.write(newfilename, filecontent)
|
43
|
+
# on sauve la ligne
|
44
|
+
file_to_save=file_to_save+line+"\n"
|
45
|
+
|
46
|
+
|
47
|
+
else
|
48
|
+
#it's a online gem require we add the line
|
49
|
+
|
50
|
+
file_to_save=file_to_save+line
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
else
|
59
|
+
file_to_save=file_to_save+line
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
File.write(current_folder+'/diamonds/user_app/main.rb', file_to_save)
|
70
|
+
File.write(current_folder+'/diamonds/user_app/ID_Repository.txt', "0")
|
71
|
+
File.write(current_folder+'/diamonds/apps/user_app.rb', "")
|
72
|
+
exec "cd #{File.expand_path(current_folder)}/diamonds/;bundle install;bundle exec rackup -p9292 -o 0.0.0.0 -E production -q -s thin"
|
73
|
+
# exec "cd #{File.expand_path(current_folder)}/diamonds/;bundle exec rackup -p9292 -o 0.0.0.0 -E production -q -s thin"
|
74
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Gemfile
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
gemspec
|
4
|
+
# specs
|
5
|
+
gem "rack"
|
6
|
+
gem "rake"
|
7
|
+
gem "json"
|
8
|
+
gem "rufus-scheduler"
|
9
|
+
gem "tilt"
|
10
|
+
gem "sequel"
|
11
|
+
gem "fileutils"
|
12
|
+
gem "sinatra"
|
13
|
+
gem "sinatra-websocket"
|
14
|
+
gem "sinatra-contrib"
|
15
|
+
gem "thin" # webrick has a bug with safari
|
16
|
+
gem "opal-rspec"
|
17
|
+
gem "opal-jquery"
|
18
|
+
gem "sqlite3"
|
19
|
+
# gem "sinatra/reloader"
|
20
|
+
|
21
|
+
# runner
|
22
|
+
gem 'selenium-webdriver', require: false
|
23
|
+
gem 'rest-client', require: false
|
24
|
+
|
25
|
+
# browser
|
26
|
+
gem 'opal'
|
27
|
+
gem 'paggio', github: 'meh/paggio'
|
28
|
+
|
@@ -0,0 +1,254 @@
|
|
1
|
+
#to launch server if first launch ever then : bundle install
|
2
|
+
# Then to run server : bundle exec rackup
|
3
|
+
# exemple bundle exec rackup -p9292 -o 62.210.129.107 -E production -q -s thin
|
4
|
+
# avec thin en ssl : thin -R config.ru -a 192.168.0.47 -p 443 start --ssl
|
5
|
+
#site sur port (-p) : 9292, adresse(-o) : 62.210.129.107 , evironement (-E) :production , quiet (-q), server(-s) thin
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
Browser support for Opal
|
32
|
+
========================
|
33
|
+
|
34
|
+
[![Build Status](https://secure.travis-ci.org/opal/opal-browser.svg?branch=master)](http://travis-ci.org/opal/opal-browser)
|
35
|
+
[![Gem Version](https://badge.fury.io/rb/opal-browser.svg)](http://badge.fury.io/rb/opal-browser)
|
36
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/opal/opal-browser.svg)](https://codeclimate.com/github/opal/opal-browser)
|
37
|
+
|
38
|
+
|
39
|
+
This library aims to be a full-blown wrapper for all the browser API including
|
40
|
+
HTML5.
|
41
|
+
|
42
|
+
Usage
|
43
|
+
=====
|
44
|
+
|
45
|
+
_Server side (config.ru, Rakefile, Rails, Sinatra, etc.)_
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'opal-browser'
|
49
|
+
# Your server code here
|
50
|
+
```
|
51
|
+
|
52
|
+
_Browser side_
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'opal'
|
56
|
+
require 'browser'
|
57
|
+
# Your Opal code here
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
Features
|
63
|
+
========
|
64
|
+
This is a list of the currently wrapped features and some details on them.
|
65
|
+
|
66
|
+
DOM
|
67
|
+
---
|
68
|
+
DOM support is complete as far as I know, it has a very Nokogiri feel to it
|
69
|
+
with obvious differences where relevant (for instance, event handling).
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
$document.ready do
|
73
|
+
alert "yo dawg, I'm all loaded up in here"
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
It also supports a markaby inspired builder DSL which generates DOM nodes
|
78
|
+
directly instead of creating a string.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
$document.ready do
|
82
|
+
DOM {
|
83
|
+
div.info {
|
84
|
+
span.red "I'm all cooked up."
|
85
|
+
}
|
86
|
+
}.append_to($document.body)
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
CSSOM
|
91
|
+
-----
|
92
|
+
CSSOM support is still incomplete but the useful parts are implemented, this
|
93
|
+
includes a DSL for generating a CSS style and the same DSL is also used to
|
94
|
+
change style declarations (which can either belong to a `DOM::Element` or a
|
95
|
+
`CSS::Rule::Style`).
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
$document.body.style.apply {
|
99
|
+
background color: 'black'
|
100
|
+
color 'white'
|
101
|
+
font family: 'Verdana'
|
102
|
+
}
|
103
|
+
```
|
104
|
+
|
105
|
+
AJAX & SJAX
|
106
|
+
-----------
|
107
|
+
The `XMLHttpRequest` API has been wrapped completely, it also optionally
|
108
|
+
supports binary results as typed-arrays.
|
109
|
+
|
110
|
+
It easily allows for synchronous and asynchronous requests.
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
Browser::HTTP.get "/something.json" do
|
114
|
+
on :success do |res|
|
115
|
+
alert res.json.inspect
|
116
|
+
end
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
WebSocket
|
121
|
+
---------
|
122
|
+
Websockets have been fully wrapped and they are easily configurable with
|
123
|
+
blocks.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
Browser::Socket.new 'ws://echo.websocket.org' do
|
127
|
+
on :open do
|
128
|
+
every 1 do
|
129
|
+
puts "ping"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
on :message do |e|
|
134
|
+
log "Received #{e.data}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
EventSource
|
140
|
+
-----------
|
141
|
+
Event sources have been implemented and are easily configurable with blocks.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
Browser::EventSource.new '/events' do |es|
|
145
|
+
es.on :message do |e|
|
146
|
+
alert e.data
|
147
|
+
end
|
148
|
+
|
149
|
+
es.on :custom do |e|
|
150
|
+
alert "custom #{e.data}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
```
|
154
|
+
|
155
|
+
History
|
156
|
+
-------
|
157
|
+
The HTML5 History API has been fully wrapped.
|
158
|
+
|
159
|
+
Storage
|
160
|
+
-------
|
161
|
+
The HTML5 Storage API has been wrapped and it exports a single Storage class
|
162
|
+
that uses the most appropriate and available API to store data locally.
|
163
|
+
|
164
|
+
Database SQL
|
165
|
+
------------
|
166
|
+
WebSQL has been fully wrapped.
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
db = Browser::Database::SQL.new 'test'
|
170
|
+
db.transaction {|t|
|
171
|
+
t.query('CREATE TABLE test(ID INTEGER PRIMARY KEY ASC, text TEXT)').then {
|
172
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 1, 'huehue')
|
173
|
+
}.then {
|
174
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 2, 'jajaja')
|
175
|
+
}.then {
|
176
|
+
t.query('SELECT * FROM test')
|
177
|
+
}.then {|r|
|
178
|
+
r.each {|row|
|
179
|
+
alert row.inspect
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
```
|
184
|
+
|
185
|
+
Browser support
|
186
|
+
===============
|
187
|
+
|
188
|
+
* Internet Explorer 6+
|
189
|
+
* Firefox (Current - 1) or Current
|
190
|
+
* Chrome (Current - 1) or Current
|
191
|
+
* Safari 5.1+
|
192
|
+
* Opera 12.1x or (Current - 1) or Current
|
193
|
+
|
194
|
+
Any problem above browsers should be considered and reported as a bug.
|
195
|
+
|
196
|
+
(Current - 1) or Current denotes that we support the current stable version of
|
197
|
+
the browser and the version that preceded it. For example, if the current
|
198
|
+
version of a browser is 24.x, we support the 24.x and 23.x versions.
|
199
|
+
|
200
|
+
12.1x or (Current - 1) or Current denotes that we support Opera 12.1x as well
|
201
|
+
as last 2 versions of Opera. For example, if the current Opera version is 20.x,
|
202
|
+
we support Opera 12.1x, 19.x and 20.x but not Opera 15.x through 18.x.
|
203
|
+
|
204
|
+
Cross-browser testing sponsored by [BrowserStack](http://browserstack.com).
|
205
|
+
|
206
|
+
CSS selectors
|
207
|
+
-------------
|
208
|
+
Older browsers do not support CSS selector in queries, this means you'll need
|
209
|
+
external polyfills for this.
|
210
|
+
|
211
|
+
The suggested polyfill is [Sizzle](http://sizzlejs.com/), require it **before**
|
212
|
+
opal-browser.
|
213
|
+
|
214
|
+
JSON parsing
|
215
|
+
------------
|
216
|
+
Older browsers don't support JSON parsing natively, this means you'll need
|
217
|
+
external polyfills for this.
|
218
|
+
|
219
|
+
The suggested polyfill is [json2](https://github.com/douglascrockford/JSON-js),
|
220
|
+
require it **before** opal-browser.
|
221
|
+
|
222
|
+
XPath support
|
223
|
+
-------------
|
224
|
+
Not all browsers support XPath queries, I'm looking at you Internet Explorer,
|
225
|
+
this means you'll need external polyfills for this.
|
226
|
+
|
227
|
+
The suggested polyfill is
|
228
|
+
[wgxpath](https://code.google.com/p/wicked-good-xpath/), require it **before**
|
229
|
+
opal-browser.
|
230
|
+
|
231
|
+
License
|
232
|
+
=======
|
233
|
+
|
234
|
+
(The MIT License)
|
235
|
+
|
236
|
+
Copyright (C) 2014 by meh
|
237
|
+
|
238
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
239
|
+
of this software and associated documentation files (the "Software"), to deal
|
240
|
+
in the Software without restriction, including without limitation the rights
|
241
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
242
|
+
copies of the Software, and to permit persons to whom the Software is
|
243
|
+
furnished to do so, subject to the following conditions:
|
244
|
+
|
245
|
+
The above copyright notice and this permission notice shall be included in
|
246
|
+
all copies or substantial portions of the Software.
|
247
|
+
|
248
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
249
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
250
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
251
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
252
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
253
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
254
|
+
THE SOFTWARE.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "opal"
|
2
|
+
require "opal-jquery"
|
3
|
+
require "opal-parser"
|
4
|
+
require "json"
|
5
|
+
require "browser"
|
6
|
+
require "browser/location"
|
7
|
+
require "browser/socket"
|
8
|
+
|
9
|
+
|
10
|
+
Document.ready? do
|
11
|
+
@page_name= `window.location.pathname`
|
12
|
+
require "library"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,321 @@
|
|
1
|
+
serverpath = Native `window.location.host + window.location.pathname`
|
2
|
+
@page_adress= Native `window.location.pathname`.split("/")[1]
|
3
|
+
# alert @page_adress
|
4
|
+
@edit_mode="move"
|
5
|
+
serverpath="ws://"+serverpath
|
6
|
+
|
7
|
+
@activeFlow=Browser::Socket.new serverpath do
|
8
|
+
on :open do
|
9
|
+
Element.find("body").append("<div id='page_content' class='editablecontent'></div>")
|
10
|
+
Element.find("body").append("<div id='master_items' ></div>")
|
11
|
+
end
|
12
|
+
|
13
|
+
on :message do |message_received|
|
14
|
+
message_received= JSON.parse(message_received.data)
|
15
|
+
# ------------------ read_page ici ----------------
|
16
|
+
Element.find("#page_content").append(message_received)
|
17
|
+
#------------------ a modifier pour mise en base -----------------#
|
18
|
+
require "user_app"
|
19
|
+
#------------------ a modifier pour mise en base -----------------#
|
20
|
+
end
|
21
|
+
|
22
|
+
on :close do
|
23
|
+
Element.find("body").html("Bye bye")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def montest
|
29
|
+
alert "mon test succeed !!!"
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_default_page
|
33
|
+
|
34
|
+
|
35
|
+
Element.find("body").append("<div id='menubox' class='menubox'></div>")
|
36
|
+
Element.find("#menubox").append("<div id='edittoggle' class='edit'>Edit</div>")
|
37
|
+
Element.find("#edittoggle").on :click do
|
38
|
+
# l'action "list_modules_number" recupere le nombre total de module et le stock dans un attr dans la div moduleutil
|
39
|
+
@activeFlow.send({:action => "list_modules_number", :pass => "pass"}.to_json);
|
40
|
+
|
41
|
+
def move_or_edit_fct
|
42
|
+
if @edit_mode=="move"
|
43
|
+
@edit_mode="edit"
|
44
|
+
# alert "edit"
|
45
|
+
remove_drag
|
46
|
+
elsif @edit_mode=="edit"
|
47
|
+
@edit_mode="move"
|
48
|
+
# alert "move"
|
49
|
+
make_it_draggable
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
edittoggle=Element.find(".editablecontent")
|
54
|
+
if edittoggle.has_class?("wysiwyg-editor")
|
55
|
+
if edittoggle.attr("contenteditable")=="true"
|
56
|
+
Element.find("#menus_container").remove
|
57
|
+
edittoggle.remove_attr("contenteditable")
|
58
|
+
remove_drag
|
59
|
+
elsif edittoggle.attr("contenteditable").nil?
|
60
|
+
create_default_objet
|
61
|
+
bind_save
|
62
|
+
bind_tools
|
63
|
+
make_it_draggable
|
64
|
+
edittoggle.attr("contenteditable", "true")
|
65
|
+
end
|
66
|
+
else
|
67
|
+
create_default_objet
|
68
|
+
bind_save
|
69
|
+
bind_tools
|
70
|
+
make_it_draggable
|
71
|
+
Native `editcontent()`
|
72
|
+
end
|
73
|
+
end
|
74
|
+
Native `$('#menubox').draggable()`
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def create_default_objet
|
80
|
+
# Creation du container d'outil ici
|
81
|
+
Element.find("#menubox").append("<div id='menus_container' class='menus_container'></div>")
|
82
|
+
# add the tools
|
83
|
+
|
84
|
+
Element.find("#menus_container").append("<div id='save_page' class='save_page'>Save</div>")
|
85
|
+
Element.find("#menus_container").append("<div id='toolbox' class='toolbox'></div>")
|
86
|
+
Element.find("#toolbox").append("<div id='tools' class='tools'>Tools List</div>")
|
87
|
+
Element.find("#menus_container").append("<div id='modulebox' class='modulebox'></div>")
|
88
|
+
Element.find("#modulebox").append("<div id='module_utils' class='module_utils'>Modules</div>")
|
89
|
+
bind_modules_utils
|
90
|
+
end
|
91
|
+
|
92
|
+
set_default_page
|
93
|
+
|
94
|
+
def bindHref
|
95
|
+
Element.find("a").on :mousedown do |acontent|
|
96
|
+
@startime=gettime
|
97
|
+
end
|
98
|
+
|
99
|
+
Element.find("a").on :mouseup do |acontent|
|
100
|
+
# tester si l'editeur est ouvert plutot que la difference de temps
|
101
|
+
@endtime= gettime
|
102
|
+
totaltime=@endtime-@startime
|
103
|
+
editionstate= Element.find("#authentifier").css("display")
|
104
|
+
|
105
|
+
begin
|
106
|
+
if editionstate=="block"
|
107
|
+
end
|
108
|
+
rescue
|
109
|
+
editionstate="none"
|
110
|
+
|
111
|
+
end
|
112
|
+
pass=Element.find("#passhere").text
|
113
|
+
target =acontent.current_target.attr("href")
|
114
|
+
|
115
|
+
if editionstate=="block"
|
116
|
+
if totaltime >1000
|
117
|
+
Native `window.location.href = #{target}+'?pass='+#{pass}`
|
118
|
+
end
|
119
|
+
else
|
120
|
+
Native `window.location.href = #{target}+'?pass='+#{pass}`
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def bind_create_module
|
129
|
+
Element.find("#module_creator").on :click do
|
130
|
+
|
131
|
+
number_of_modules=`$('#module_utils').attr('number_of_modules')`
|
132
|
+
id= "mon_module_nb_#{number_of_modules}"
|
133
|
+
classname= "editablecontent modules"
|
134
|
+
name= "les infos"
|
135
|
+
content=" module vide"
|
136
|
+
|
137
|
+
Element.find("#master_items").append("<div id='#{id}' class='#{classname}' name='#{name}'>#{content}</div>")
|
138
|
+
Native `$('.modules').draggable()`
|
139
|
+
# On incremente temporarirement le nombre de module dans modules_utils
|
140
|
+
number_of_modules=number_of_modules.to_i+1
|
141
|
+
number_of_modules=number_of_modules.to_s
|
142
|
+
Element.find("#module_utils").attr("number_of_modules", number_of_modules)
|
143
|
+
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def bind_modules_utils
|
149
|
+
|
150
|
+
Element.find("#module_utils").on :click do
|
151
|
+
elementexist= Element.find("#module_creator").attr :id
|
152
|
+
if elementexist.nil?
|
153
|
+
Element.find("#modulebox").append("<div id='modules_container' class='modules_container'></div>")
|
154
|
+
Element.find("#modules_container").append("<div id='module_creator' class='module_creator'>New</div>")
|
155
|
+
Element.find("#modules_container").append("<div id='modules_list' class='modules_list'>list</div>")
|
156
|
+
Element.find("#modules_container").append("<div id='modules_on_page' class='modules_on_page'>on page</div>")
|
157
|
+
Element.find("#modules_container").append("<div id='module_infos' class='module_infos'>infos</div>")
|
158
|
+
bind_create_module
|
159
|
+
bind_modules_list
|
160
|
+
bind_modules_on_page
|
161
|
+
else
|
162
|
+
Element.find("#modules_container").remove
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def bind_tools
|
169
|
+
Element.find("#tools").on :click do
|
170
|
+
elementexist= Element.find("#tool_handler").attr :id
|
171
|
+
if elementexist.nil?
|
172
|
+
|
173
|
+
Element.find("#toolbox").append("<div id='tools_container' class='tools_container'></div>")
|
174
|
+
Element.find("#tools_container").append("<div id='tool_handler' class='tool_handler'></div>")
|
175
|
+
Element.find("#tool_handler").append("<div id='move_or_edit' class='move_or_edit'>mover</div>")
|
176
|
+
Element.find("#move_or_edit").on :click do
|
177
|
+
# alert "edit or move"
|
178
|
+
move_or_edit_fct
|
179
|
+
end
|
180
|
+
|
181
|
+
else
|
182
|
+
Element.find("#tools_container").remove
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
def bind_save
|
192
|
+
Element.find("#save_page").on :click do
|
193
|
+
|
194
|
+
editablecontent = Element.find(".modules")
|
195
|
+
list_of_modules_on_page=[]
|
196
|
+
editablecontent.each do |content|
|
197
|
+
item_id= content.id.to_sym
|
198
|
+
list_of_modules_on_page << item_id
|
199
|
+
module_content= Native `get_full_object(#{item_id})`
|
200
|
+
save_module ({item_id => module_content})
|
201
|
+
end
|
202
|
+
#--------- pour na pas sauvegarder en double les objets systemes créé en code --------#
|
203
|
+
temp_item=Element.find(".system_object")
|
204
|
+
`$( ".system_object").remove()`
|
205
|
+
#--------- pour na pas sauvegarder en double les objets systemes créé en code --------#
|
206
|
+
page_content= Element.find("#page_content")
|
207
|
+
item_id= @page_adress
|
208
|
+
save_list_of_modules_on_page ({item_id => list_of_modules_on_page})
|
209
|
+
item_to_save=page_content.html
|
210
|
+
save_page ({item_id => item_to_save})
|
211
|
+
#--------- pour na pas sauvegarder en double les objets systemes créé en code --------#
|
212
|
+
Element.find("#page_content").append(temp_item)
|
213
|
+
#--------- pour na pas sauvegarder en double les objets systemes créé en code --------#
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
def bind_modules_list
|
219
|
+
Element.find("#modules_list").on :click do
|
220
|
+
@activeFlow.send({:action => "read_modules_list", :pass => "pass"}.to_json);
|
221
|
+
Timeout.new 1000 do
|
222
|
+
Element.find(".module_available").on :click do |evt|
|
223
|
+
module_requested= evt.current_target.html
|
224
|
+
@activeFlow.send({:action => "get_module", :pagecontent => module_requested, :currentpage => @page_adress, :pass => "pass"}.to_json);
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def bind_modules_on_page
|
231
|
+
Element.find("#modules_on_page").on :click do
|
232
|
+
# page_content= Element.find("#page_content")
|
233
|
+
# title= page_content.id.to_sym
|
234
|
+
if @page_adress.nil?
|
235
|
+
@page_adress=""
|
236
|
+
end
|
237
|
+
@activeFlow.send({:action => "read_modules_on_page", :currentpage => @page_adress, :pass => "pass"}.to_json);
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
def save_page (datas)
|
243
|
+
pass= Element.find('#passhere').text
|
244
|
+
key, value = datas.first
|
245
|
+
title=key
|
246
|
+
content= value
|
247
|
+
@activeFlow.send({:action => "save", :pagecontent => content, :currentpage => @page_adress, :pass => "pass"}.to_json);
|
248
|
+
end
|
249
|
+
|
250
|
+
def save_module (datas)
|
251
|
+
# pass= Element.find('#passhere').text
|
252
|
+
# alert "save module : #{datas}"
|
253
|
+
key, value = datas.first
|
254
|
+
title=key
|
255
|
+
content= value
|
256
|
+
# module_content=Element.find("##{title}")
|
257
|
+
@activeFlow.send({:action => "save_module", :pagecontent => content, :currentpage => title, :pass => "pass"}.to_json);
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
def save_list_of_modules_on_page (datas)
|
262
|
+
# alert "modules sur la page sont : #{datas}"
|
263
|
+
key, value = datas.first
|
264
|
+
title=key
|
265
|
+
content= value
|
266
|
+
@activeFlow.send({:action => "save_list_of_modules_on_page", :pagecontent => content, :currentpage => @page_adress, :pass => "pass"}.to_json);
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
def read_file (datas)
|
272
|
+
alert "ou ici"
|
273
|
+
pass= Element.find('#passhere').text
|
274
|
+
key, value = datas.first
|
275
|
+
title=key
|
276
|
+
title= value
|
277
|
+
@activeFlow.send({:action => "read", :currentpage => value, :pass => pass}.to_json);
|
278
|
+
end
|
279
|
+
|
280
|
+
def read_sensor (datas)
|
281
|
+
pass= Element.find('#passhere').text
|
282
|
+
key, value = datas.first
|
283
|
+
title= value
|
284
|
+
@activeFlow.send({:action => "readsensor", :currentpage => value, :pass => pass}.to_json);
|
285
|
+
end
|
286
|
+
|
287
|
+
|
288
|
+
%x{
|
289
|
+
$("a").click(function( event ) {
|
290
|
+
event.preventDefault();
|
291
|
+
});
|
292
|
+
}
|
293
|
+
|
294
|
+
|
295
|
+
class Timeout
|
296
|
+
def initialize(time=0, &block)
|
297
|
+
`setTimeout(function(){#{block.call}}, time)`
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
def make_it_draggable
|
303
|
+
|
304
|
+
# Native `$('#toolbox').draggable()`
|
305
|
+
Native `$('.modules').draggable()`
|
306
|
+
Native `$('.editablecontent').find("img").draggable()`
|
307
|
+
Native `$('.editablecontent').find("div").not(".system_object").draggable()`
|
308
|
+
# Native `$('.editablecontent').find("span").draggable()`
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
def remove_drag
|
313
|
+
|
314
|
+
make_it_draggable
|
315
|
+
# Native `$('#toolbox').draggable('destroy')`
|
316
|
+
Native `$('.modules').draggable('destroy')`
|
317
|
+
Native `$('.editablecontent').find('img').draggable('destroy')`
|
318
|
+
Native `$('.editablecontent').find('div').draggable('destroy')`
|
319
|
+
|
320
|
+
end
|
321
|
+
|