home_page_music 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ede2fa1167564e4a92280f2f494ec97ddec5bdd0
4
+ data.tar.gz: 3449301db0c5e559f9f753521300827a675f82d1
5
+ SHA512:
6
+ metadata.gz: 4cf66fa48597931b94bc989f51a0e74ed45b1525d0fff2026a0302b640775dc0e6b47c9e73249ff9889cd1dbba9aa5142ed1bd885610ac6f643f9eee97e0d6ae
7
+ data.tar.gz: 611cb6067e2ce29253fa300ba0da5987fa268f6d987e720cd7db54bc008b1d716d60c66a53ffde16851c796d6a57589959c5e404530dff54ceefafe9cb51993f
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Mathias Gawlista
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = HomePageMusic
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'HomePageMusic'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
@@ -0,0 +1,4 @@
1
+ class Music::HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,60 @@
1
+ class Music::YearInReviewsController < ApplicationController
2
+ before_filter :show_breadcrumbs
3
+
4
+ def index
5
+ begin
6
+ @year_in_reviews = JSON.parse(
7
+ HTTParty.get("#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/api/v1/users/#{Volontariat::USER_ID}/library/music/year_in_reviews.json?page=#{params[:page]}").body
8
+ )
9
+ rescue JSON::ParserError
10
+ end
11
+
12
+ if @year_in_reviews.nil?
13
+ flash[:alert] = I18n.t('general.volontariat.request_failed')
14
+ @year_in_reviews = { 'entries' => [] }
15
+ else
16
+ @pagination = HomePage::PaginationMetadata.new(@year_in_reviews)
17
+ end
18
+ end
19
+
20
+ def show
21
+ begin
22
+ @year_in_review = JSON.parse(
23
+ HTTParty.get("#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/api/v1/users/#{Volontariat::USER_ID}/library/music/year_in_reviews/#{params[:id]}.json").body
24
+ )
25
+ rescue JSON::ParserError
26
+ end
27
+
28
+ raise ActiveRecord::RecordNotFound if @year_in_review.nil?
29
+ end
30
+
31
+ def top_albums
32
+ @year_in_review = { 'year' => params[:id] }
33
+
34
+ begin
35
+ @albums = JSON.parse(
36
+ HTTParty.get("#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/api/v1/users/#{Volontariat::USER_ID}/library/music/year_in_reviews/#{params[:id]}/top_releases.json").body
37
+ )
38
+ rescue JSON::ParserError
39
+ end
40
+
41
+ raise ActiveRecord::RecordNotFound if @albums.nil?
42
+ end
43
+
44
+ def top_songs
45
+ @year_in_review = { 'year' => params[:id] }
46
+
47
+ begin
48
+ @songs = JSON.parse(
49
+ HTTParty.get("#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/api/v1/users/#{Volontariat::USER_ID}/library/music/year_in_reviews/#{params[:id]}/top_tracks.json").body
50
+ )
51
+ rescue JSON::ParserError
52
+ end
53
+
54
+ raise ActiveRecord::RecordNotFound if @songs.nil?
55
+ end
56
+
57
+ def resource
58
+ @year_in_review
59
+ end
60
+ end
File without changes
@@ -0,0 +1,35 @@
1
+ <% if @year_in_reviews['entries'].none? %>
2
+ <p><%= t('music_year_in_reviews.index.empty_collection') %></p>
3
+ <% else %>
4
+ <table class="table table-striped">
5
+ <thead>
6
+ <tr class="<%= cycle('odd', 'even') %>">
7
+ <th style="width: 45px"><%= t("general.year") %></th>
8
+ <th style="width: 100px"></th>
9
+ <th></th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% @year_in_reviews['entries'].each do |year_in_review| %>
14
+ <tr class="<%= cycle('odd', 'even') %>">
15
+ <td>
16
+ <%= link_to year_in_review['year'], music_year_in_review_path(year_in_review['year']) %>
17
+ </td>
18
+ <td>
19
+ <%= link_to(
20
+ t('music_year_in_reviews.show.top_albums.short_title'),
21
+ music_year_in_review_top_albums_path(year_in_review['year'])
22
+ ) %>
23
+ </td>
24
+ <td>
25
+ <%= link_to(
26
+ t('music_year_in_reviews.show.top_songs.short_title'),
27
+ music_year_in_review_top_songs_path(year_in_review['year'])
28
+ ) %>
29
+ </td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+
34
+ <%= will_paginate @pagination, renderer: BootstrapPagination::Rails %>
35
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% content_for :title do %><%= t('music_year_in_reviews.index.title') %><% end %>
2
+
3
+ <div id="music_year_in_reviews">
4
+ <%= render partial: 'music/year_in_reviews/collection' %>
5
+ </div>
@@ -0,0 +1,16 @@
1
+ <% content_for :title do %><%= t('music_year_in_reviews.show.title', year: params[:id]) %><% end %>
2
+
3
+ <ul class="nav nav-pills nav-stacked">
4
+ <li>
5
+ <%= link_to(
6
+ t('music_year_in_reviews.show.top_albums.short_title'),
7
+ top_albums_music_year_in_review_path(params[:id])
8
+ ) %>
9
+ </li>
10
+ <li>
11
+ <%= link_to(
12
+ t('music_year_in_reviews.show.top_songs.short_title'),
13
+ top_songs_music_year_in_review_path(params[:id])
14
+ ) %>
15
+ </li>
16
+ </ul>
@@ -0,0 +1,31 @@
1
+ <% content_for :title do %><%= t('music_year_in_reviews.show.top_albums.title', year: params[:id]) %><% end %>
2
+
3
+ <% if @albums.none? %>
4
+ <p><%= t('music_year_in_reviews.show.top_albums.empty_collection') %></p>
5
+ <% else %>
6
+ <table class="table table-striped">
7
+ <thead>
8
+ <tr class="<%= cycle('odd', 'even') %>">
9
+ <th style="width: 50px; vertical-align:top;"><%= t('general.position') %></th>
10
+ <th style="width: 200px; vertical-align:top;"><%= t('music.general.music_artist.short') %></th>
11
+ <th style="width: 200px; vertical-align:top;"><%= t('general.name') %></th>
12
+ <th style="width: 67px; vertical-align:top;"><%= t('music_year_in_reviews.show.top_track_positions_sum')%></th>
13
+ <th style="width: 300px; vertical-align:top;"><%= t('music_year_in_reviews.show.top_songs.short_title') %></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @albums.each do |album| %>
18
+ <tr class="<%= cycle('odd', 'even') %>">
19
+ <td><%= album['position'] %></td>
20
+ <td><%= link_to album['artist_name'], "#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/music/artists/#{album['artist_id']}" %></td>
21
+ <td><%= link_to album['release_name'], "#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/music/releases/#{album['release_id']}" %></td>
22
+ <td><%= album['top_track_positions_sum'] %></td>
23
+ <td>
24
+ <%= raw(album['top_tracks'].map do |t|
25
+ "#{t['position']}. " + link_to(t['track_name'], "#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/music/tracks/#{t['track_id']}")
26
+ end.join(', ')) %>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </table>
31
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <% content_for :title do %><%= t('music_year_in_reviews.show.top_songs.title', year: params[:id]) %><% end %>
2
+
3
+ <% if @songs.none? %>
4
+ <p><%= t('music_year_in_reviews.show.top_songs.empty_collection') %></p>
5
+ <% else %>
6
+ <table class="table table-striped">
7
+ <thead>
8
+ <tr class="<%= cycle('odd', 'even') %>">
9
+ <th style="width: 50px; vertical-align:top;"><%= t('general.position') %></th>
10
+ <th style="width: 200px; vertical-align:top;"><%= t('music.general.music_artist.short') %></th>
11
+ <th style="width: 200px; vertical-align:top;"><%= t('general.name') %></th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% @songs.each do |song| %>
16
+ <tr class="<%= cycle('odd', 'even') %>">
17
+ <td><%= song['position'] %></td>
18
+ <td><%= link_to song['artist_name'], "#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/music/artists/#{song['artist_id']}" %></td>
19
+ <td><%= link_to song['track_name'], "#{Volontariat::HOSTS[Rails.env.to_s.to_sym]}/music/tracks/#{song['track_id']}" %></td>
20
+ </tr>
21
+ <% end %>
22
+ </table>
23
+ <% end %>
@@ -0,0 +1,8 @@
1
+ en:
2
+ music:
3
+ index:
4
+ title: Music
5
+
6
+ general:
7
+ music_artist:
8
+ short: Artist
@@ -0,0 +1,21 @@
1
+ en:
2
+ music_year_in_reviews:
3
+ index:
4
+ title: Music Year in Reviews
5
+ short_title: Year in Reviews
6
+ empty_collection: No year in reviews available.
7
+
8
+ show:
9
+ title: "Music Year in Review %{year}"
10
+ short_title: "Year in Review %{year}"
11
+ top_track_positions_sum: Top Track Positions Sum
12
+
13
+ top_albums:
14
+ title: Top Albums %{year}
15
+ short_title: Top Albums
16
+ empty_collection: No top albums available.
17
+
18
+ top_songs:
19
+ title: Top Songs %{year}
20
+ short_title: Top Songs
21
+ empty_collection: No top songs available.
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ Rails.application.routes.draw do
2
+ namespace :music do
3
+ resources :year_in_reviews, only: [:index, :show] do
4
+ member do
5
+ get :top_albums
6
+ get :top_songs
7
+ end
8
+ end
9
+ end
10
+
11
+ get 'music' => 'music/home#index', as: :music
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'home_page'
2
+
3
+ require 'home_page_music/navigation'
4
+
5
+ require "home_page_music/engine"
6
+
7
+ module HomePageMusic
8
+ end
@@ -0,0 +1,7 @@
1
+ module HomePageMusic
2
+ class Engine < ::Rails::Engine
3
+ config.autoload_paths << File.expand_path("../../../app/models/concerns", __FILE__)
4
+ config.autoload_paths << File.expand_path("../../../app/controllers/concerns", __FILE__)
5
+ config.i18n.load_path += Dir[File.expand_path("../../../config/locales/**/*.{rb,yml}", __FILE__)]
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ module HomePageMusic
2
+ module Navigation
3
+ def self.menu_code(resource)
4
+ case resource
5
+ when :music
6
+ Proc.new do |primary, options|
7
+ primary.item :music, I18n.t('music.index.title'), music_path do |music|
8
+ music.item :year_in_reviews, I18n.t('music_year_in_reviews.index.title'), music_year_in_reviews_path do |year_in_reviews|
9
+ if @year_in_review.present?
10
+ year_in_reviews.item :show, @year_in_review['year'], music_year_in_review_path(@year_in_review['year']) do |year_in_review|
11
+ year_in_review.item :top_albums, I18n.t('music_year_in_reviews.show.top_albums.short_title'), top_albums_music_year_in_review_path(@year_in_review['year'])
12
+ year_in_review.item :top_songs, I18n.t('music_year_in_reviews.show.top_songs.short_title'), top_songs_music_year_in_review_path(@year_in_review['year'])
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,3 @@
1
+ module HomePageMusic
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :home_page_music do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: home_page_music
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mathias Gawlista
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: home_page
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Music module for home_page gem.
42
+ email:
43
+ - gawlista@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.rdoc
50
+ - Rakefile
51
+ - app/controllers/music/home_controller.rb
52
+ - app/controllers/music/year_in_reviews_controller.rb
53
+ - app/views/music/home/index.html.erb
54
+ - app/views/music/year_in_reviews/_collection.html.erb
55
+ - app/views/music/year_in_reviews/index.html.erb
56
+ - app/views/music/year_in_reviews/show.html.erb
57
+ - app/views/music/year_in_reviews/top_albums.html.erb
58
+ - app/views/music/year_in_reviews/top_songs.html.erb
59
+ - config/locales/resources/music/en.yml
60
+ - config/locales/resources/music_year_in_reviews/en.yml
61
+ - config/routes.rb
62
+ - lib/home_page_music.rb
63
+ - lib/home_page_music/engine.rb
64
+ - lib/home_page_music/navigation.rb
65
+ - lib/home_page_music/version.rb
66
+ - lib/tasks/home_page_music_tasks.rake
67
+ homepage: http://Blog.Home-Page.Software
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.5
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Music module for home_page gem.
91
+ test_files: []