diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 96b2dabf..f836c5ce 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -36,3 +36,7 @@ $(document).on 'page:change ready', -> $(document).on 'page:load', -> # Reload polyfill when turbolinks loads a new page $(this).updatePolyfill() + +$(document).ready -> + $("img").error -> + $(this).hide() diff --git a/app/assets/stylesheets/list.css.sass b/app/assets/stylesheets/list.css.sass index 0a813c9d..dd49d398 100644 --- a/app/assets/stylesheets/list.css.sass +++ b/app/assets/stylesheets/list.css.sass @@ -7,10 +7,11 @@ table padding: 0.3em 0.6em &.list - tr:nth-child(odd) - background-color: #D1EAFF - tr:nth-child(even) - background-color: #C9E2F5 + tbody + tr:nth-child(odd) + background-color: #D1EAFF + tr:nth-child(even) + background-color: #C9E2F5 th font-size: larger td @@ -22,13 +23,19 @@ dl margin: 1em auto max-width: 40em dt + clear: left float: left padding: 0.2em 1em - .quantity + min-width: 50% text-align: right dd padding: 0.2em 1em border-top: 1px solid #999 + text-align: left + &.quantity + text-align: right + h3 + display: inline .view_link:link, .edit_link:link, .delete_link:link font-size: 0 diff --git a/app/assets/stylesheets/lugs.sass b/app/assets/stylesheets/lugs.sass new file mode 100644 index 00000000..537cb9e8 --- /dev/null +++ b/app/assets/stylesheets/lugs.sass @@ -0,0 +1,6 @@ +@import "compass" + +img.favicon + max-height: 2em + vertical-align: middle + @include border-radius(3px) diff --git a/app/assets/stylesheets/mobile.css.sass b/app/assets/stylesheets/mobile.css.sass index 2ec84ae1..f6db3872 100644 --- a/app/assets/stylesheets/mobile.css.sass +++ b/app/assets/stylesheets/mobile.css.sass @@ -1,5 +1,5 @@ @media all and (min-width: 1600px) - body.events.index table + main font-size: larger sidebar#lug-list diff --git a/app/assets/stylesheets/moderations.css.sass b/app/assets/stylesheets/moderations.css.sass index 3fcbf8a5..9f61d7e6 100644 --- a/app/assets/stylesheets/moderations.css.sass +++ b/app/assets/stylesheets/moderations.css.sass @@ -5,8 +5,6 @@ h2.warning table.list min-width: 90% margin-top: 15px - thead tr - background-color: transparent td padding-top: 0.5em padding-bottom: 0.5em diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 85a50a5a..35322653 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -4,6 +4,9 @@ class EventsController < ApplicationController before_filter :set_mailer_host def index + # So we can use the search form from the central calendar page + @search = Lug.search params[:q] + @events = Event.moderated if params[:region] && params[:region].present? && params[:region] != 'all' @events = @events.region params[:region] diff --git a/app/controllers/lugs_controller.rb b/app/controllers/lugs_controller.rb new file mode 100644 index 00000000..02c68a8b --- /dev/null +++ b/app/controllers/lugs_controller.rb @@ -0,0 +1,30 @@ +class LugsController < ApplicationController + before_action :set_lug, only: [:show] + + def index + @search = Lug.search params[:q] + @search.sorts = 'name' if @search.sorts.empty? + @lugs = @search.result().page params[:page] + end + + def show + @search = Lug.search params[:q] + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_lug + @lug = Lug.find params[:id] + + set_meta_tags title: @lug.name, + description: @lug.url, + DC: { + title: @lug.name + }, + geo: { + region: @lug.related_region, + placename: @lug.city, + position: "#{@lug.related_city.try :latitude};#{@lug.related_city.try :longitude}" + } + end +end diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml index 720f74a4..1a417217 100644 --- a/app/views/events/index.html.haml +++ b/app/views/events/index.html.haml @@ -54,3 +54,5 @@ tag: params[:tag], protocol: 'webcal', format: :ics, tag: params[:tag], region: params[:region])), ical: link_to('iCal', events_url(:rss, tag: params[:tag], format: :ics, tag: params[:tag], region: params[:region])) + += render '/lugs/search' diff --git a/app/views/lugs/_search.html.haml b/app/views/lugs/_search.html.haml new file mode 100644 index 00000000..f9032f6a --- /dev/null +++ b/app/views/lugs/_search.html.haml @@ -0,0 +1,8 @@ +%h2 + %em.fa.fa-users + = title t '.title', entity: Lug.model_name.human + += search_form_for @search do |f| + = f.label :name_cont + = f.search_field :name_cont + = f.submit diff --git a/app/views/lugs/index.html.haml b/app/views/lugs/index.html.haml new file mode 100644 index 00000000..f82fa8e5 --- /dev/null +++ b/app/views/lugs/index.html.haml @@ -0,0 +1,30 @@ += render 'search' + +%table.list.autopagerize_page_element + %thead + %th= sort_link @search, :name + %th= sort_link @search, :city + %th= sort_link @search, :department + %th= sort_link @search, :related_region_name, Lug.human_attribute_name(:related_region) + %th= sort_link @search, :url + %th/ + + %tbody + - @lugs.each do |lug| + %tr + %td + = lug.name + %td + = lug.city + %td + = lug.department + %td + = lug.related_region + %td + - if lug.url =~ /^http/ + = image_tag lug.url+'/favicon.ico', alt: '', class: :favicon + = link_to lug.url, lug.url + %td + = link_to t('show'), lug_url(lug, q: params[:q]), class: :view_link + += paginate @lugs diff --git a/app/views/lugs/show.html.haml b/app/views/lugs/show.html.haml new file mode 100644 index 00000000..22faab04 --- /dev/null +++ b/app/views/lugs/show.html.haml @@ -0,0 +1,24 @@ += render 'search' + +%dl + %dt= Lug.human_attribute_name :name + %dd + %h3 + = image_tag @lug.url+'/favicon.ico', alt: '', class: :favicon + = @lug.name + %dt= Lug.human_attribute_name :city + %dd= @lug.city + %dt= Lug.human_attribute_name :department + %dd= @lug.department + %dt= Lug.human_attribute_name :related_region + %dd= @lug.related_region + %dt= Lug.human_attribute_name :url + %dd= link_to @lug.url, @lug.url + +%iframe(src="#{@lug.url}" width='1000' height='400' frameborder='none' + allowTransparency='true') + +%nav + = link_to lugs_path(q: params[:q]), class: :back do + %em.fa.fa-arrow-left + = Lug.model_name.human.pluralize diff --git a/config/database.yml b/config/database.yml index eb9f4fb5..c85bd421 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,4 +1,4 @@ -development: +developmen: adapter: sqlite3 pool: 5 timeout: 5000 @@ -13,7 +13,8 @@ test: timeout: 5000 database: db/test.sqlite3 -production: +#production: +development: adapter: mysql2 encoding: utf8 database: adl_fr diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 8755bc88..4951e850 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -244,10 +244,8 @@ Exemple: `%{daylimit}`" sign_in: title: Identification lugs: - index: - title: Groupes d'Utilisateurs de Logiciels Libres - show: - title: Groupe d'Utilisateurs de Logiciels Libres + search: + title: Trouve ton %{entity}! devise: sessions: diff --git a/config/locales/kaminari.fr.yml b/config/locales/kaminari.fr.yml new file mode 100644 index 00000000..5c88bb18 --- /dev/null +++ b/config/locales/kaminari.fr.yml @@ -0,0 +1,9 @@ +fr: + views: + pagination: + first: "«" + last: "»" + previous: "‹" + next: "›" + truncate: "..." + diff --git a/test/controllers/lugs_controller_test.rb b/test/controllers/lugs_controller_test.rb new file mode 100644 index 00000000..4ae99e5b --- /dev/null +++ b/test/controllers/lugs_controller_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' + +class LugsControllerTest < ActionController::TestCase + setup do + @lug = lugs :one + end + + test "should get index" do + get :index + assert_response :success + end + + test "should get show" do + get :show, id: @lug + assert_response :success + end +end