crimson 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gempush.yml +44 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/.vscode/launch.json +14 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/crimson.gemspec +25 -0
- data/example/ets.rb +22 -0
- data/example/example.rb +66 -0
- data/lib/crimson.js +10 -0
- data/lib/crimson.rb +5 -0
- data/lib/crimson/client.rb +86 -0
- data/lib/crimson/icons/close.png +0 -0
- data/lib/crimson/icons/hide.png +0 -0
- data/lib/crimson/icons/resize.png +0 -0
- data/lib/crimson/mash.rb +9 -0
- data/lib/crimson/model.rb +98 -0
- data/lib/crimson/model_change.rb +20 -0
- data/lib/crimson/notification_bus.rb +35 -0
- data/lib/crimson/object.rb +196 -0
- data/lib/crimson/server.rb +69 -0
- data/lib/crimson/utilities.rb +13 -0
- data/lib/crimson/version.rb +3 -0
- data/lib/crimson/webserver.rb +17 -0
- data/lib/crimson/widgets/bottom_resizer.rb +22 -0
- data/lib/crimson/widgets/desktop.rb +44 -0
- data/lib/crimson/widgets/form.rb +12 -0
- data/lib/crimson/widgets/input.rb +10 -0
- data/lib/crimson/widgets/left_resizer.rb +27 -0
- data/lib/crimson/widgets/resizer.rb +38 -0
- data/lib/crimson/widgets/right_resizer.rb +22 -0
- data/lib/crimson/widgets/taskbar.rb +0 -0
- data/lib/crimson/widgets/titlebar.rb +75 -0
- data/lib/crimson/widgets/top_resizer.rb +27 -0
- data/lib/crimson/widgets/window.rb +134 -0
- data/lib/html/template.html +13 -0
- data/lib/javascript/Application.js +13 -0
- data/lib/javascript/Logger.js +11 -0
- data/lib/javascript/MessageHandler.js +142 -0
- data/lib/javascript/ObjectManager.js +33 -0
- data/lib/javascript/ServerInteractor.js +42 -0
- data/lib/javascript/Utilities.js +26 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a5da65ea222585d02e2af5148b3e4f3b51d1bb1b1a119879484e320717e88674
|
4
|
+
data.tar.gz: 9b11f71db1c618a53df6ac15028d3d7eb76d1fb8773484be30349f65ae754813
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46eacb8d903a59a88a8375791ced6686000e273914355b10950c48e77b777cf43ccc05fd0f081590a1ace4275d0b74c9df8eaf23275e8ba5cbe0b67cda50970e
|
7
|
+
data.tar.gz: 5ec837a1e8871c71a8c3a09091c263da16414e9b8c878ae83fa12df455f1c0201a2060cc6266e8512a72a0a4da65df19c45ae340ef3a9fe16a11faac0c392b20
|
@@ -0,0 +1,44 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
name: Build + Publish
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@master
|
18
|
+
- name: Set up Ruby 2.6
|
19
|
+
uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
version: 2.6.x
|
22
|
+
|
23
|
+
- name: Publish to GPR
|
24
|
+
run: |
|
25
|
+
mkdir -p $HOME/.gem
|
26
|
+
touch $HOME/.gem/credentials
|
27
|
+
chmod 0600 $HOME/.gem/credentials
|
28
|
+
printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
29
|
+
gem build *.gemspec
|
30
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
31
|
+
env:
|
32
|
+
GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
|
33
|
+
OWNER: username
|
34
|
+
|
35
|
+
- name: Publish to RubyGems
|
36
|
+
run: |
|
37
|
+
mkdir -p $HOME/.gem
|
38
|
+
touch $HOME/.gem/credentials
|
39
|
+
chmod 0600 $HOME/.gem/credentials
|
40
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
41
|
+
gem build *.gemspec
|
42
|
+
gem push *.gem
|
43
|
+
env:
|
44
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/.vscode/launch.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
3
|
+
// Hover to view descriptions of existing attributes.
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5
|
+
"version": "0.2.0",
|
6
|
+
"configurations": [
|
7
|
+
{
|
8
|
+
"name": "Debug Local File",
|
9
|
+
"type": "Ruby",
|
10
|
+
"request": "launch",
|
11
|
+
"program": "${workspaceRoot}/example/ets.rb"
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at rizwan@ualberta.ca. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Rizwan Qureshi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Crimson
|
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/crimson`. 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 'crimson'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install crimson
|
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. Then, run `rake test` to run the tests. 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/rizwan146/crimson. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "crimson"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/crimson.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'crimson/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "crimson"
|
8
|
+
spec.version = Crimson::VERSION
|
9
|
+
spec.authors = ["Rizwan Qureshi"]
|
10
|
+
spec.email = ["rizwan@ualberta.ca"]
|
11
|
+
|
12
|
+
spec.summary = %q{Develop server-sided web-apps using Ruby!}
|
13
|
+
spec.description = %q{This library helps you write server-sided web apps using Ruby.}
|
14
|
+
spec.homepage = "https://github.com/rizwan146/crimson"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
25
|
+
end
|
data/example/ets.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../crimson'
|
4
|
+
require_relative '../lib/ruby/widgets/desktop'
|
5
|
+
|
6
|
+
# server = Crimson::Server.new
|
7
|
+
|
8
|
+
# desktop = Crimson::Desktop.new
|
9
|
+
# desktop.style.backgroundColor = 'black'
|
10
|
+
# desktop.commit_tree!
|
11
|
+
|
12
|
+
# server.on_connect do |client|
|
13
|
+
# puts "#{client.id} connected"
|
14
|
+
|
15
|
+
# client.observe(desktop)
|
16
|
+
# end
|
17
|
+
|
18
|
+
# server.on_disconnect do |client|
|
19
|
+
# puts "#{client.id} disconnected"
|
20
|
+
# end
|
21
|
+
|
22
|
+
# server.run
|
data/example/example.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'crimson'
|
4
|
+
require 'crimson/widgets/desktop'
|
5
|
+
require 'crimson/widgets/window'
|
6
|
+
require 'crimson/widgets/form'
|
7
|
+
require 'crimson/widgets/input'
|
8
|
+
|
9
|
+
server = Crimson::Server.new
|
10
|
+
|
11
|
+
desktop = Crimson::Desktop.new
|
12
|
+
desktop.style.backgroundColor = "white"
|
13
|
+
|
14
|
+
username = Crimson::Input.new(:text)
|
15
|
+
username.name = "username"
|
16
|
+
username.placeholder = "Username"
|
17
|
+
username.style.width = "50%"
|
18
|
+
username.style.height = "30px"
|
19
|
+
|
20
|
+
password = Crimson::Input.new(:password)
|
21
|
+
password.name = "password"
|
22
|
+
password.placeholder = "Password"
|
23
|
+
password.style.width = "50%"
|
24
|
+
password.style.height = "30px"
|
25
|
+
|
26
|
+
submit = Crimson::Input.new(:submit)
|
27
|
+
submit.value = "Login"
|
28
|
+
submit.style.marginTop = '20px'
|
29
|
+
submit.style.width = "50%"
|
30
|
+
submit.style.height = "30px"
|
31
|
+
submit.style.backgroundColor = 'rgba(46, 204, 113, 1)'
|
32
|
+
submit.style.color = 'white'
|
33
|
+
submit.style.border = 0
|
34
|
+
|
35
|
+
form = Crimson::Form.new
|
36
|
+
form.style.display = 'flex'
|
37
|
+
form.style.justifyContent = 'center'
|
38
|
+
form.style.alignItems = 'center'
|
39
|
+
form.style.flexDirection = 'column'
|
40
|
+
form.style.height = "100%"
|
41
|
+
form.add(username)
|
42
|
+
form.add(password)
|
43
|
+
form.add(submit)
|
44
|
+
|
45
|
+
form.on("submit") do |data|
|
46
|
+
puts "Username: #{data.username}, Password: #{data.password}"
|
47
|
+
end
|
48
|
+
|
49
|
+
login = desktop.create_window("Login", "400px", "200px")
|
50
|
+
login.titlebar.buttons.each(&:hide)
|
51
|
+
login.resizable = false
|
52
|
+
login.content = form
|
53
|
+
|
54
|
+
desktop.commit_tree!
|
55
|
+
|
56
|
+
server.on_connect do |client|
|
57
|
+
puts "#{client.id} connected"
|
58
|
+
|
59
|
+
client.observe(desktop)
|
60
|
+
end
|
61
|
+
|
62
|
+
server.on_disconnect do |client|
|
63
|
+
puts "#{client.id} disconnected"
|
64
|
+
end
|
65
|
+
|
66
|
+
server.run
|
data/lib/crimson.js
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import Application from './javascript/Application.js'
|
2
|
+
|
3
|
+
let __crimson_apps__ = [];
|
4
|
+
|
5
|
+
document.addEventListener('DOMContentLoaded', function() {
|
6
|
+
const applications = [... document.getElementsByTagName('crimson')]
|
7
|
+
applications.forEach(function(application, index){
|
8
|
+
__crimson_apps__.push( new Application(application) );
|
9
|
+
});
|
10
|
+
});
|
data/lib/crimson.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'hashie'
|
4
|
+
require_relative 'notification_bus'
|
5
|
+
|
6
|
+
module Crimson
|
7
|
+
class Client
|
8
|
+
attr_reader :id, :connection, :notification_bus
|
9
|
+
|
10
|
+
def initialize(id, connection)
|
11
|
+
@id = id
|
12
|
+
|
13
|
+
@connection = connection
|
14
|
+
@connection.onmessage(&method(:on_message))
|
15
|
+
|
16
|
+
@notification_bus = NotificationBus.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_message(message, type)
|
20
|
+
message = Hashie::Mash.new(JSON.parse(message))
|
21
|
+
|
22
|
+
begin
|
23
|
+
case message.action
|
24
|
+
when "event"
|
25
|
+
notification_bus.notify(message)
|
26
|
+
end
|
27
|
+
rescue ArgumentError => e
|
28
|
+
puts e
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def write(message = {})
|
33
|
+
connection.send(message.to_json)
|
34
|
+
end
|
35
|
+
|
36
|
+
def on_commit(object, changes)
|
37
|
+
write(
|
38
|
+
action: :update,
|
39
|
+
id: object.id,
|
40
|
+
changes: changes
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def observe(object)
|
45
|
+
object.postordered_each do |observable|
|
46
|
+
write(
|
47
|
+
action: :create,
|
48
|
+
id: observable.id,
|
49
|
+
tag: observable.tag,
|
50
|
+
changes: observable.master
|
51
|
+
)
|
52
|
+
|
53
|
+
observable.add_observer(self)
|
54
|
+
notification_bus.register(observable)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def unobserve(object)
|
59
|
+
object.postordered_each do |observable|
|
60
|
+
observable.remove_observer(self)
|
61
|
+
notification_bus.unregister(observable)
|
62
|
+
|
63
|
+
write(
|
64
|
+
action: :destroy,
|
65
|
+
id: observable.id
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def observing?(object)
|
71
|
+
object.observers.key?(self)
|
72
|
+
end
|
73
|
+
|
74
|
+
def ==(other)
|
75
|
+
other.is_a?(Client) && other.id == id
|
76
|
+
end
|
77
|
+
|
78
|
+
def eql?(other)
|
79
|
+
self == other
|
80
|
+
end
|
81
|
+
|
82
|
+
def hash
|
83
|
+
id.hash
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|