concerto_weather 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +13 -0
- data/README.md +7 -0
- data/Rakefile +27 -0
- data/app/assets/stylesheets/concerto_weather/application.css +13 -0
- data/app/controllers/concerto_weather/application_controller.rb +4 -0
- data/app/helpers/concerto_weather/application_helper.rb +4 -0
- data/app/models/weather.rb +29 -0
- data/app/views/contents/weather/_form_top.html +11 -0
- data/app/views/contents/weather/_render_default.html.erb +10 -0
- data/app/views/contents/weather/_render_tile.html.erb +1 -0
- data/app/views/layouts/concerto_weather/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/lib/concerto_weather/engine.rb +9 -0
- data/lib/concerto_weather/version.rb +3 -0
- data/lib/concerto_weather.rb +4 -0
- data/lib/tasks/concerto_weather_tasks.rake +4 -0
- metadata +86 -0
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
              Copyright 2013 Concerto Authors
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            +
            you may not use this file except in compliance with the License.
         | 
| 5 | 
            +
            You may obtain a copy of the License at
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            +
            distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            +
            WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            +
            See the License for the specific language governing permissions and
         | 
| 13 | 
            +
            limitations under the License.
         | 
    
        data/README.md
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            #!/usr/bin/env rake
         | 
| 2 | 
            +
            begin
         | 
| 3 | 
            +
              require 'bundler/setup'
         | 
| 4 | 
            +
            rescue LoadError
         | 
| 5 | 
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         | 
| 6 | 
            +
            end
         | 
| 7 | 
            +
            begin
         | 
| 8 | 
            +
              require 'rdoc/task'
         | 
| 9 | 
            +
            rescue LoadError
         | 
| 10 | 
            +
              require 'rdoc/rdoc'
         | 
| 11 | 
            +
              require 'rake/rdoctask'
         | 
| 12 | 
            +
              RDoc::Task = Rake::RDocTask
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         | 
| 16 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 17 | 
            +
              rdoc.title    = 'ConcertoWeather'
         | 
| 18 | 
            +
              rdoc.options << '--line-numbers'
         | 
| 19 | 
            +
              rdoc.rdoc_files.include('README.rdoc')
         | 
| 20 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
             | 
| 26 | 
            +
            Bundler::GemHelper.install_tasks
         | 
| 27 | 
            +
             | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            /*
         | 
| 2 | 
            +
             * This is a manifest file that'll be compiled into application.css, which will include all the files
         | 
| 3 | 
            +
             * listed below.
         | 
| 4 | 
            +
             *
         | 
| 5 | 
            +
             * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
         | 
| 6 | 
            +
             * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
         | 
| 7 | 
            +
             *
         | 
| 8 | 
            +
             * You're free to add application-wide styles to this file and they'll appear at the top of the
         | 
| 9 | 
            +
             * compiled file, but it's generally better to create a new file per style scope.
         | 
| 10 | 
            +
             *
         | 
| 11 | 
            +
             *= require_self
         | 
| 12 | 
            +
             *= require_tree .
         | 
| 13 | 
            +
             */
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            class Weather < DynamicContent
         | 
| 2 | 
            +
              DISPLAY_NAME = 'Weather'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def build_content
         | 
| 5 | 
            +
                require 'rss'
         | 
| 6 | 
            +
                require 'net/http'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                url = "http://weather.yahooapis.com/forecastrss?p=#{self.config['zip_code']}"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                feed = Net::HTTP.get_response(URI.parse(url)).body
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                rss = RSS::Parser.parse(feed, false, true)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                weather_data = rss.items.first
         | 
| 15 | 
            +
                sanitized_data = weather_data.description
         | 
| 16 | 
            +
                htmltext = HtmlText.new()
         | 
| 17 | 
            +
                htmltext.name = weather_data.title
         | 
| 18 | 
            +
                rawhtml = "<h1>#{rss.channel.title}</h1><i>#{weather_data.title}</i><p>#{sanitized_data}</p>"
         | 
| 19 | 
            +
                Rails.logger.debug rawhtml
         | 
| 20 | 
            +
                htmltext.data = ActionController::Base.helpers.sanitize(rawhtml, :tags => ['i', 'img', 'b', 'br', 'p', 'h1'])
         | 
| 21 | 
            +
                return [htmltext]
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              # Weather needs a location.
         | 
| 25 | 
            +
              def self.form_attributes
         | 
| 26 | 
            +
                attributes = super()
         | 
| 27 | 
            +
                attributes.concat([:config => [:zip_code]])
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            <fieldset>
         | 
| 2 | 
            +
              <legend><span>Weather</span></legend>
         | 
| 3 | 
            +
              <%= form.fields_for :config do |config| %>
         | 
| 4 | 
            +
                <div class="clearfix">
         | 
| 5 | 
            +
                  <%= config.label :zip_code %>
         | 
| 6 | 
            +
                  <div class="input">
         | 
| 7 | 
            +
                    <%= config.text_field 'zip_code', :placeholder => '12180', :size => 10 %>
         | 
| 8 | 
            +
                  </div>
         | 
| 9 | 
            +
                </div>
         | 
| 10 | 
            +
              <% end %>
         | 
| 11 | 
            +
            </fieldset>
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            <dl>
         | 
| 2 | 
            +
              <dt>Zip Code</dt>
         | 
| 3 | 
            +
              <dd><%= content.config['zip_code'] %></dd>
         | 
| 4 | 
            +
              <dt>Last Successful Update</dt>
         | 
| 5 | 
            +
              <dd><%= content.config.include?('last_ok_refresh') ? Time.at(content.config['last_ok_refresh']).strftime('%c') : 'Never' %></dd>
         | 
| 6 | 
            +
              <dt>Last Attempted Update</dt>
         | 
| 7 | 
            +
              <dd><%= content.config.include?('last_refresh_attempt') ? distance_of_time_in_words_to_now(Time.at(content.config['last_refresh_attempt'])).titleize : 'Never' %> Ago</dd>
         | 
| 8 | 
            +
              <dt>Min. Refresh Interval</dt>
         | 
| 9 | 
            +
              <dd><%= distance_of_time_in_words(content.config['interval'].to_i) %></dd>
         | 
| 10 | 
            +
            </dl>
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <h1>Weather for <%= content.config['zip_code'] %></h1>
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html>
         | 
| 3 | 
            +
            <head>
         | 
| 4 | 
            +
              <title>ConcertoWeather</title>
         | 
| 5 | 
            +
              <%= stylesheet_link_tag    "concerto_weather/application", :media => "all" %>
         | 
| 6 | 
            +
              <%= javascript_include_tag "concerto_weather/application" %>
         | 
| 7 | 
            +
              <%= csrf_meta_tags %>
         | 
| 8 | 
            +
            </head>
         | 
| 9 | 
            +
            <body>
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            <%= yield %>
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            </body>
         | 
| 14 | 
            +
            </html>
         | 
    
        data/config/routes.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,86 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: concerto_weather
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Brian Michalski
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-03-19 00:00:00.000000000 -07:00
         | 
| 13 | 
            +
            default_executable: 
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            +
              name: rails
         | 
| 17 | 
            +
              requirement: &70183968575400 !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                none: false
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - ~>
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 3.2.12
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: *70183968575400
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 27 | 
            +
              name: sqlite3
         | 
| 28 | 
            +
              requirement: &70183968574960 !ruby/object:Gem::Requirement
         | 
| 29 | 
            +
                none: false
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ! '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: *70183968574960
         | 
| 37 | 
            +
            description: Show the current weather and a short forecast in the sidebar of Concerto
         | 
| 38 | 
            +
              2.
         | 
| 39 | 
            +
            email:
         | 
| 40 | 
            +
            - bmichalski@gmail.com
         | 
| 41 | 
            +
            executables: []
         | 
| 42 | 
            +
            extensions: []
         | 
| 43 | 
            +
            extra_rdoc_files: []
         | 
| 44 | 
            +
            files:
         | 
| 45 | 
            +
            - app/assets/stylesheets/concerto_weather/application.css
         | 
| 46 | 
            +
            - app/controllers/concerto_weather/application_controller.rb
         | 
| 47 | 
            +
            - app/helpers/concerto_weather/application_helper.rb
         | 
| 48 | 
            +
            - app/models/weather.rb
         | 
| 49 | 
            +
            - app/views/contents/weather/_form_top.html
         | 
| 50 | 
            +
            - app/views/contents/weather/_render_default.html.erb
         | 
| 51 | 
            +
            - app/views/contents/weather/_render_tile.html.erb
         | 
| 52 | 
            +
            - app/views/layouts/concerto_weather/application.html.erb
         | 
| 53 | 
            +
            - config/routes.rb
         | 
| 54 | 
            +
            - lib/concerto_weather/engine.rb
         | 
| 55 | 
            +
            - lib/concerto_weather/version.rb
         | 
| 56 | 
            +
            - lib/concerto_weather.rb
         | 
| 57 | 
            +
            - lib/tasks/concerto_weather_tasks.rake
         | 
| 58 | 
            +
            - LICENSE
         | 
| 59 | 
            +
            - Rakefile
         | 
| 60 | 
            +
            - README.md
         | 
| 61 | 
            +
            has_rdoc: true
         | 
| 62 | 
            +
            homepage: https://github.com/concerto/concerto-weather
         | 
| 63 | 
            +
            licenses: []
         | 
| 64 | 
            +
            post_install_message: 
         | 
| 65 | 
            +
            rdoc_options: []
         | 
| 66 | 
            +
            require_paths:
         | 
| 67 | 
            +
            - lib
         | 
| 68 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 69 | 
            +
              none: false
         | 
| 70 | 
            +
              requirements:
         | 
| 71 | 
            +
              - - ! '>='
         | 
| 72 | 
            +
                - !ruby/object:Gem::Version
         | 
| 73 | 
            +
                  version: '0'
         | 
| 74 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 75 | 
            +
              none: false
         | 
| 76 | 
            +
              requirements:
         | 
| 77 | 
            +
              - - ! '>='
         | 
| 78 | 
            +
                - !ruby/object:Gem::Version
         | 
| 79 | 
            +
                  version: '0'
         | 
| 80 | 
            +
            requirements: []
         | 
| 81 | 
            +
            rubyforge_project: 
         | 
| 82 | 
            +
            rubygems_version: 1.6.2
         | 
| 83 | 
            +
            signing_key: 
         | 
| 84 | 
            +
            specification_version: 3
         | 
| 85 | 
            +
            summary: Weather plugin for Concerto 2.
         | 
| 86 | 
            +
            test_files: []
         |