astronomy_engine 0.0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc163ed7ab5163f914ea00c0ddb13c2482714200
4
- data.tar.gz: 4fc04e6d5ce1b2344813b5ff08b79af05e1d7831
3
+ metadata.gz: e73f373599f23325492d9a1e392fc11da2d1824d
4
+ data.tar.gz: c069e0ff45f23febf748bdd5b82344c6c83d462e
5
5
  SHA512:
6
- metadata.gz: 7ef6bc5f0bc57a91dc3047bc70f60819c534980db48d5b6b231851c418642771a39057233051f4a5baa64ee50807619e8c72725d633a95dae418ebfe35858a77
7
- data.tar.gz: 983e616f20903f6d807e5352a51a953329d2facd5cdbb0313e8e050f1511d8d8a59d59c418506a431a71d1fd8d9221fc1dea8e3ac10f775e4e146fc7ce0a01b7
6
+ metadata.gz: 09af144a4e60b5a6546d4119ab9c9323b05a8889dc4471df1e5c8eabecaf450a6ff61aa0b479ed65c094ddc339c43a8ac65de01b0498b1b6c1cffd6399d180e5
7
+ data.tar.gz: 0ccb9090715c690d1d248d8b8bc68252e50756a303c5b1a8151d1172d60df1cea29e2072b25c9640a3d48fdfa394c6cc54f152c7e273c07c4799732c3410c8a7
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A mountable engine for the `astronomy` gem
4
4
 
5
+ ![Screenshot](/screenshot/example.jpg?raw=true "Screenshot")
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.7'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
- spec.add_development_dependency 'capybara', '~> 2.4'
24
23
  spec.add_development_dependency 'rspec', '~> 3.0'
25
24
 
26
25
  spec.add_runtime_dependency 'sinatra', '~> 1.4'
27
26
  spec.add_runtime_dependency 'sinatra-contrib', '~> 1.4'
27
+ spec.add_runtime_dependency 'sinatra-assetpack', '~> 0.3'
28
28
  spec.add_runtime_dependency 'astronomy', '~> 0.2'
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module AstronomyEngine
2
- VERSION = "0.0.1"
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,13 +1,28 @@
1
1
  require 'astronomy_engine/version'
2
- require 'sinatra'
3
2
  require 'astronomy'
3
+
4
+ require 'sinatra'
5
+ require 'sinatra/assetpack'
4
6
  require 'sinatra/json'
5
7
 
6
8
  module AstronomyEngine
7
9
  class App < Sinatra::Base
8
10
  helpers Sinatra::JSON
11
+ register Sinatra::AssetPack
9
12
 
13
+ set :root, File.join(File.dirname(__FILE__), 'public')
10
14
  set :astronomy, Astronomy::Information.new
15
+ assets {
16
+ serve '/js', from: 'js'
17
+ serve '/css', from: 'css'
18
+ }
19
+
20
+ get '/' do
21
+ content_type 'text/html'
22
+ path = File.join(settings.root, 'index.html')
23
+ send_file path
24
+ end
25
+
11
26
  before { content_type 'application/json' }
12
27
 
13
28
  get '/categories' do
@@ -0,0 +1,16 @@
1
+ * {
2
+ font-family: sans-serif;
3
+ }
4
+
5
+ .space-above {
6
+ margin-top: 20px;
7
+ }
8
+
9
+ .initially-hidden {
10
+ display: none;
11
+ }
12
+
13
+ .image-padding {
14
+ margin: 5px;
15
+ vertical-align: top;
16
+ }
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Astronomical Data</title>
5
+ <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
6
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
7
+ <script src="js/main.js"></script>
8
+ <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
9
+ <link rel="stylesheet" type="text/css" href="css/style.css">
10
+ </head>
11
+ </html>
12
+
13
+ <div class="space-above"></div>
14
+ <div class="container-fluid">
15
+ <div class="col-md-3">
16
+ <div id="categories" class="list-group"></div>
17
+ </div>
18
+ <div class="col-md-3">
19
+ <div id="topics" class="list-group initially-hidden"></div>
20
+ </div>
21
+ <div class="col-md-6">
22
+ <div id="topic" class="panel panel-default initially-hidden">
23
+ <div class="panel-heading">
24
+ <h3 id="topic-title" class="panel-title"></h3>
25
+ </div>
26
+ <div id="topic-body" class="panel-body">
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
@@ -0,0 +1,55 @@
1
+ $(document).ready(function () {
2
+ $.ajax({
3
+ url: 'categories',
4
+ type: 'GET',
5
+ success: function (data) {
6
+ categories = $('#categories');
7
+ for (var i in data) {
8
+ var elem = $('<a href="#" class="list-group-item">' + data[i] + '</a>');
9
+ categories.append(elem);
10
+ }
11
+ }
12
+ });
13
+
14
+ $('#categories').on('click', function(event) {
15
+ var category = $(event.target).text();
16
+ $.ajax({
17
+ url: 'categories/' + category + '/topics',
18
+ type: 'GET',
19
+ success: function (data) {
20
+ topics = $('#topics');
21
+ topics.empty();
22
+ for (var i in data) {
23
+ //var elem = $('<div class="list-group-item">' + data[i].name + '</div>');
24
+ //elem.data('foo', 'bar');
25
+ var elem = $('<a href="#" class="list-group-item">' + data[i].name + '</a>');
26
+ elem.data('name', data[i].name);
27
+ elem.data('description', data[i].description);
28
+ elem.data('images', data[i].images);
29
+ topics.append(elem);
30
+ }
31
+ topics.fadeIn();
32
+ }
33
+ });
34
+ })
35
+
36
+ $('#topics').on('click', function(event) {
37
+ var target = $(event.target);
38
+ $('#topic').fadeIn();
39
+ $('#topic-title').text(target.data('name'));
40
+ var images = '<div>';
41
+ for(var i in target.data('images')) {
42
+ var keyinfo = "key=AIzaSyAbwKdX2k3t5M6hpAwDpcDCWHTBxtfRvMg";
43
+ var image = target.data('images')[i] + "?" + keyinfo;
44
+ images += '<img src="' + image + '&maxwidth=200" class="image-padding">';
45
+ }
46
+ images += '</div>';
47
+ var description = addLineBreaks(target.data('description'));
48
+ $('#topic-body').html(images + description);
49
+ });
50
+
51
+ });
52
+
53
+ function addLineBreaks(text) {
54
+ return text.replace(/(?:\r\n|\r|\n)/g, '<div class="space-above"></div>');
55
+ }
Binary file
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1 @@
1
- require 'astronomy_engine'
2
- require 'capybara/rspec'
3
-
4
- RSpec.configure do |config|
5
- config.include Capybara::DSL
6
-
7
- config.before do
8
- Capybara.app = AstronomyEngine::App
9
- end
10
- end
1
+ require 'astronomy_engine'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astronomy_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Aschenbach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-25 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,35 +39,35 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: capybara
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.4'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.4'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: sinatra
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
61
+ version: '1.4'
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
- name: sinatra
70
+ name: sinatra-contrib
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.4'
83
83
  - !ruby/object:Gem::Dependency
84
- name: sinatra-contrib
84
+ name: sinatra-assetpack
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.4'
89
+ version: '0.3'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.4'
96
+ version: '0.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: astronomy
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +124,10 @@ files:
124
124
  - astronomy_engine.gemspec
125
125
  - lib/astronomy_engine.rb
126
126
  - lib/astronomy_engine/version.rb
127
+ - lib/public/css/style.css
128
+ - lib/public/index.html
129
+ - lib/public/js/main.js
130
+ - screenshot/example.jpg
127
131
  - spec/astronomy_engine_spec.rb
128
132
  - spec/spec_helper.rb
129
133
  homepage: https://github.com/nick-aschenbach/astronomy-engine