diff --git a/app/assets/javascripts/ajax.coffee b/app/assets/javascripts/ajax.coffee index 9e98402..ead40ba 100644 --- a/app/assets/javascripts/ajax.coffee +++ b/app/assets/javascripts/ajax.coffee @@ -17,6 +17,11 @@ class window.Ajax _ajax.setTitle 'About' false + loadStatPage: -> + $('#content').load '/stat/' + _ajax.setTitle 'Statistics' + false + setArchor: (anchor) -> @referer = this.getAnchor() window.location.hash = '#' +anchor @@ -41,6 +46,8 @@ class window.Ajax _settings.loadSettingsPage() else if _ajax.getAnchor().match /\/about\// _ajax.loadAboutPage() + else if _ajax.getAnchor().match /\/stat\// + _ajax.loadStatPage() else _ajax.loadIndexPage(); false diff --git a/app/assets/javascripts/page.coffee b/app/assets/javascripts/page.coffee index afcb0f3..235fadc 100644 --- a/app/assets/javascripts/page.coffee +++ b/app/assets/javascripts/page.coffee @@ -35,6 +35,9 @@ $ -> $('.about').live 'click', -> _ajax.go '/about/' false + $('.stat').live 'click', -> + _ajax.go '/stat/' + false $('body').live 'click', -> $('.dropdown-toggle, .menu').parent('li').removeClass('open') false diff --git a/app/assets/stylesheets/misc.scss b/app/assets/stylesheets/misc.scss index d2bc3ed..78ba596 100644 --- a/app/assets/stylesheets/misc.scss +++ b/app/assets/stylesheets/misc.scss @@ -24,4 +24,8 @@ padding: 200px 20px; font-size: 20px; text-align: center; +} + +table.stats { + width: 50%; } \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8ef8485..b2436ad 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,6 +15,14 @@ class ApplicationController < ActionController::Base render partial: 'about' end + def stat + @artists = Artist.count + @albums = Album.count + @tracks = Track.count + @users = User.count + render partial: 'stat' + end + protected def authorize diff --git a/app/views/application/_stat.en.html.haml b/app/views/application/_stat.en.html.haml new file mode 100644 index 0000000..ae511bf --- /dev/null +++ b/app/views/application/_stat.en.html.haml @@ -0,0 +1,19 @@ +%h2 BeatHaven statistics + +%table.zebra-striped.stats + %tr + %td + %strong Artists + %td= @artists + %tr + %td + %strong Albums + %td= @albums + %tr + %td + %strong Tracks + %td= @tracks + %tr + %td + %strong Users + %td= @users diff --git a/app/views/application/_stat.ru.html.haml b/app/views/application/_stat.ru.html.haml new file mode 100644 index 0000000..24eda4f --- /dev/null +++ b/app/views/application/_stat.ru.html.haml @@ -0,0 +1,19 @@ +%h2 Статистика BeatHaven + +%table.zebra-striped.stats + %tr + %td + %strong Исполнителей + %td= @artists + %tr + %td + %strong Альбомов + %td= @albums + %tr + %td + %strong Треков + %td= @tracks + %tr + %td + %strong Пользователей + %td= @users diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2a7446b..f4be847 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,7 +19,9 @@ %li %a{ :href => "http://blog.beathaven.org/", :target => "_blank" }= I18n.t 'global.news' %li - %a.about{ :href => "#/about/" }= I18n.t 'global.about' + %a.about{ :href => "#/about/" }= I18n.t 'global.about' + %li + %a.stat{ :href => "#/stat/" }= I18n.t 'global.stat' %form#search-form{ :action => "" } %input#search{ :type => "text", :placeholder => I18n.t('global.search') } #artist-load-spinner diff --git a/config/locales/en.yml b/config/locales/en.yml index 0b3545f..960dfee 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,6 +3,7 @@ en: search: "Search" news: "News" about: "About" + stat: "Statistics" login: "Log in" logout: "Log out" do_add: "Add some music to playlist" diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 8440e2d..0d8eb17 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -3,6 +3,7 @@ ru: search: "Поиск" news: "Новости" about: "О проекте" + stat: "Статистика" login: "Войти" logout: "Выйти" do_add: "Добавьте музыку в плей-лист" diff --git a/config/routes.rb b/config/routes.rb index 702fa5e..b032697 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ Beathaven::Application.routes.draw do match '/' => 'application#index' match '/greetings/' => 'application#greetings' match '/about/' => 'application#about' + match '/stat/' => 'application#stat' match 'user/auth' => 'user#auth' match 'user/update' => 'user#update'