concerto_weather 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/app/assets/fonts/concerto_weather/owfont-regular.eot +0 -0
- data/app/assets/fonts/concerto_weather/owfont-regular.otf +0 -0
- data/app/assets/fonts/concerto_weather/owfont-regular.svg +394 -0
- data/app/assets/fonts/concerto_weather/owfont-regular.ttf +0 -0
- data/app/assets/fonts/concerto_weather/owfont-regular.woff +0 -0
- data/app/assets/stylesheets/concerto_weather/application.css +1 -0
- data/app/assets/stylesheets/concerto_weather/owfont-regular.css.scss +558 -0
- data/app/models/weather.rb +39 -54
- data/app/views/contents/weather/_form_top.html.erb +2 -4
- data/app/views/contents/weather/_render_default.html.erb +2 -2
- data/app/views/contents/weather/_render_tile.html.erb +1 -1
- data/lib/concerto_weather/engine.rb +19 -0
- data/lib/concerto_weather/version.rb +1 -1
- metadata +8 -4
- data/app/assets/javascripts/concerto_weather/weather.js +0 -90
- data/app/assets/stylesheets/concerto_weather/weather.css.scss +0 -3
@@ -5,6 +5,25 @@ module ConcertoWeather
|
|
5
5
|
initializer "register content type" do |app|
|
6
6
|
app.config.content_types << Weather
|
7
7
|
end
|
8
|
+
|
9
|
+
def plugin_info(plugin_info_class)
|
10
|
+
@plugin_info ||= plugin_info_class.new do
|
11
|
+
add_config("open_weather_map_api_key", "",
|
12
|
+
value_type: "string",
|
13
|
+
category: "API Keys",
|
14
|
+
description: "OpenWeatherMap API Access Token. This token is used for obtaining weather information when adding weather content. http://openweathermap.org/appid")
|
15
|
+
|
16
|
+
# Add owfont (open weather) icon set to application layout for content preview / browsing
|
17
|
+
add_header_tags do
|
18
|
+
stylesheet_link_tag "concerto_weather/application"
|
19
|
+
end
|
8
20
|
|
21
|
+
# Add owfont (open weather) icon set to concerto-frontend layout for weather content shown on screens
|
22
|
+
add_view_hook "frontend/ScreensController", :concerto_frontend_plugins do
|
23
|
+
"#{ stylesheet_link_tag 'concerto_weather/application' }"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
9
28
|
end
|
10
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concerto_weather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Michalski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -35,10 +35,14 @@ files:
|
|
35
35
|
- LICENSE
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
|
+
- app/assets/fonts/concerto_weather/owfont-regular.eot
|
39
|
+
- app/assets/fonts/concerto_weather/owfont-regular.otf
|
40
|
+
- app/assets/fonts/concerto_weather/owfont-regular.svg
|
41
|
+
- app/assets/fonts/concerto_weather/owfont-regular.ttf
|
42
|
+
- app/assets/fonts/concerto_weather/owfont-regular.woff
|
38
43
|
- app/assets/javascripts/concerto_weather/application.js
|
39
|
-
- app/assets/javascripts/concerto_weather/weather.js
|
40
44
|
- app/assets/stylesheets/concerto_weather/application.css
|
41
|
-
- app/assets/stylesheets/concerto_weather/
|
45
|
+
- app/assets/stylesheets/concerto_weather/owfont-regular.css.scss
|
42
46
|
- app/controllers/concerto_weather/application_controller.rb
|
43
47
|
- app/helpers/concerto_weather/application_helper.rb
|
44
48
|
- app/models/weather.rb
|
@@ -1,90 +0,0 @@
|
|
1
|
-
|
2
|
-
// attach handler to woeid so when it loses focus we can look it up
|
3
|
-
// not dry, but no middle man
|
4
|
-
function attachWoeidHandlers() {
|
5
|
-
console.log('attaching woeid handlers');
|
6
|
-
|
7
|
-
$('input#weather_config_woeid').on('keyup', getWoeidInfo);
|
8
|
-
|
9
|
-
function getWoeidInfo() {
|
10
|
-
// will place name, district-county, province-state, country, woeid into 'div.woeid-info'
|
11
|
-
|
12
|
-
var info = '<p>WOEID details could not be determined.</p>';
|
13
|
-
var woeid = $('input#weather_config_woeid').val();
|
14
|
-
var info_el = $('.woeid-info');
|
15
|
-
var woeidName = $('i.woeid-name');
|
16
|
-
|
17
|
-
// something was changed, so wipe out the pre-existing woeid name
|
18
|
-
if (woeidName.length != 0) {
|
19
|
-
$(woeidName).text('');
|
20
|
-
}
|
21
|
-
|
22
|
-
if (info_el.length != 0) {
|
23
|
-
// we found the summary box
|
24
|
-
$(info_el).empty().html('<i class=\"fa fa-spinner fa-spin\"></i> searching...');
|
25
|
-
$.ajax({
|
26
|
-
url: "//query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent("select woeid, placeTypeName, name, admin1, admin2, country from geo.places where (text = \"" + woeid + "\" or woeid = \"" + woeid + "\") limit 5") + "&format=json",
|
27
|
-
dataType: 'jsonp',
|
28
|
-
timeout: 4000,
|
29
|
-
success: function (data) {
|
30
|
-
|
31
|
-
function htmlEncode(value){
|
32
|
-
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
|
33
|
-
//then grab the encoded contents back out. The div never exists on the page.
|
34
|
-
return $('<div/>').text(value).html();
|
35
|
-
}
|
36
|
-
|
37
|
-
if (data.query && data.query.count > 0 && typeof(data.query.results.place) != "undefined") {
|
38
|
-
j = data.query.results.place;
|
39
|
-
if (!(j instanceof Array)) {
|
40
|
-
j = [ data.query.results.place ];
|
41
|
-
}
|
42
|
-
|
43
|
-
// we got something, should use jq datatables with js array load
|
44
|
-
// places = []
|
45
|
-
// j.forEach(function(item) {
|
46
|
-
// places.push([item.name, item.placeTypeName.content, (item.admin1 ? item.admin1.content : ''),
|
47
|
-
// (item.admin2 ? item.admin2.content : ''), item.country.content, item.woeid]);
|
48
|
-
// });
|
49
|
-
|
50
|
-
// icky html table construction (with classes for bootstrap)
|
51
|
-
places = "<table class=\"table table-condensed\">";
|
52
|
-
places += "<thead><tr><th>Name</th><th>Type</th><th>Province/State</th><th>District/County/Region</th><th>Country</th><th>WOEID</th></th></thead>";
|
53
|
-
places += "<tbody>";
|
54
|
-
tbody = "";
|
55
|
-
j.forEach(function(item) {
|
56
|
-
// todo: need htmlencoding
|
57
|
-
tbody += "<tr class=\"link-hl\" data-woeid=\"" + item.woeid + "\"><td>" + htmlEncode(item.name) + "</td><td>" +
|
58
|
-
htmlEncode(item.placeTypeName.content) + "</td><td>" +
|
59
|
-
htmlEncode((item.admin1 ? item.admin1.content : '')) + "</td><td>" +
|
60
|
-
htmlEncode((item.admin2 ? item.admin2.content : '')) + "</td><td>" +
|
61
|
-
htmlEncode((item.country ? item.country.content : '')) + "</td><td>" +
|
62
|
-
item.woeid + "</td></tr>";
|
63
|
-
});
|
64
|
-
places += tbody + "</tbody></table>";
|
65
|
-
info = places;
|
66
|
-
}
|
67
|
-
$(info_el).empty().html(info);
|
68
|
-
// wire up the clicks on the rows to populate the woeid and name fields
|
69
|
-
$(info_el).find('tr').on('click', function (e) {
|
70
|
-
$('input#weather_config_woeid').val($(this).data('woeid'));
|
71
|
-
var name = "";
|
72
|
-
$(this).find('td').slice(2,5).each(function () {
|
73
|
-
text = $(this).text().trim();
|
74
|
-
if (text != "") {
|
75
|
-
name += (name != "" ? ", " : "") + text;
|
76
|
-
}
|
77
|
-
});
|
78
|
-
$('input#weather_name').val(name);
|
79
|
-
});
|
80
|
-
},
|
81
|
-
error: function (xoptions, textStatus) {
|
82
|
-
$(info_el).empty().html(info);
|
83
|
-
}
|
84
|
-
});
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
$(document).ready(attachWoeidHandlers);
|
90
|
-
$(document).on('page:change', attachWoeidHandlers);
|