From a0cd381d43d75f99e4ccfc927b6a1f8866bbca61 Mon Sep 17 00:00:00 2001 From: echarp Date: Sun, 24 Nov 2013 16:11:44 +0100 Subject: [PATCH] Traductions et look global en place --- app/assets/stylesheets/all.css.sass | 3 + app/controllers/application_controller.rb | 2 + app/views/layouts/_flash.html.haml | 3 + app/views/layouts/application.html.erb | 14 -- app/views/layouts/application.html.haml | 49 +++++ app/views/users/index.html.haml | 26 +-- config/database.yml | 2 +- config/locales/en.yml | 21 ++- config/locales/fr.yml | 24 ++- config/routes.rb | 2 + db/structure.sql | 215 ++++++++++++++++++++++ test/fixtures/admin_users.yml | 11 +- test/fixtures/users.yml | 12 +- 13 files changed, 342 insertions(+), 42 deletions(-) create mode 100644 app/views/layouts/_flash.html.haml delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.haml create mode 100644 db/structure.sql diff --git a/app/assets/stylesheets/all.css.sass b/app/assets/stylesheets/all.css.sass index 33bf61cd..bc66201f 100644 --- a/app/assets/stylesheets/all.css.sass +++ b/app/assets/stylesheets/all.css.sass @@ -2,3 +2,6 @@ * @include transition-duration(0.5s) + +[class^="fa-"], [class*=" fa-"] + font-family: FontAwesome, Arial, Helvetica, sans-serif !important diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e1..6c0dc609 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,6 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + before_action :authenticate_admin_user! end diff --git a/app/views/layouts/_flash.html.haml b/app/views/layouts/_flash.html.haml new file mode 100644 index 00000000..b67eec4e --- /dev/null +++ b/app/views/layouts/_flash.html.haml @@ -0,0 +1,3 @@ +#flash_messages + - flash.each do |key, value| + .flash(class="#{key}")= value diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 7c6e1d06..00000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - AgendaDuLibreRails - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - - diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 00000000..273abdc4 --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,49 @@ +!!! 5 +/[if IE] +%html(lang="#{I18n.locale}") + %head + %title AgendaDuLibreRails + + %meta(http-equiv='Content-Type' content='text/html; charset=utf-8') + + %meta(name='description' content='Parlement, a mix between direct and representative democracy, in the shape of a website. A mailing list, forum, chat. Democratic mailing list and forum') + %meta(name='author' content='Emmanuel Charpentier') + %meta(name='robots' content='index, follow') + %meta(name='keywords' content='collaborative writing, democracy, direct democracy, representative democracy, forum, mailing list, chat, Ruby on Rails, PostgreSQL') + + %meta(name='dcterms.title' content='Parlement' lang='en') + %meta(name='dcterms.title' content='Parlement' lang='fr') + %meta(name='dcterms.subject' content='Parlement, democratic mailing list and forum') + + -#%link(rel='shortcut icon' href='/assets/favicon.ico') + %link(rel='icon' type='image/png' href='/assets/world.png') + = auto_discovery_link_tag :atom, { format: :atom } + + = stylesheet_link_tag 'application', media: "all", "data-turbolinks-track" => true + = javascript_include_tag 'application', "data-turbolinks-track" => true + /[if lt IE 9] + %script(src='http://html5shiv.googlecode.com/svn/trunk/html5.js') + = csrf_meta_tags + + // = javascript_include_tag 'html5' + // = javascript_include_tag 'PIE' + // /https://github.com/aFarkas/iepp/wiki + + %body(class = "#{controller.controller_name}") + = render 'layouts/flash', flash: flash if flash.present? + + %header.top + %h1= link_to 'Agenda du libre', root_url + - if admin_user_signed_in? + - else + = link_to t('.login'), new_user_session_path, class: :login + + = yield + + %footer.bottom + %nav + = link_to User.model_name.human.capitalize.pluralize, users_url + = link_to 'Forge', 'http://rubyforge.org/projects/parlement' + = link_to 'AGPL', 'http://www.gnu.org/licenses/agpl.html' + = link_to 'fr', '/fr', class: 'fr' + %span.version=t :version, version: 1.99 diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 3db88a71..4b3d451d 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,25 +1,25 @@ -%h1 Listing users +%h1= User.model_name.human.pluralize -%table +%table.index_table %tr - %th Login - %th Email - %th Lastname - %th Firstname - %th - %th + %th= User.human_attribute_name :login + %th= User.human_attribute_name :email + %th= User.human_attribute_name :lastname + %th= User.human_attribute_name :firstname %th - @users.each do |user| - %tr + %tr(class="#{cycle('odd', 'even')}") %td= user.login %td= user.email %td= user.lastname %td= user.firstname - %td= link_to 'Show', user - %td= link_to 'Edit', edit_user_path(user) - %td= link_to 'Destroy', user, :method => :delete, :data => { :confirm => 'Are you sure?' } + %td + = link_to t('show'), user, class: 'view_link' + = link_to t('edit'), edit_user_path(user), class: 'edit_link' + = link_to t('destroy'), user, method: :delete, + data: { confirm: 'Are you sure?' }, class: 'delete_link' -%br +%br/ = link_to 'New User', new_user_path diff --git a/config/database.yml b/config/database.yml index 7fee8d29..dc83cd68 100644 --- a/config/database.yml +++ b/config/database.yml @@ -24,7 +24,7 @@ development: test: adapter: mysql2 encoding: utf8 - database: agenda-du-libre-rails_test + database: adl_test pool: 5 username: manu password: diff --git a/config/locales/en.yml b/config/locales/en.yml index 06539571..b42030e7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,4 +20,23 @@ # available at http://guides.rubyonrails.org/i18n.html. en: - hello: "Hello world" + show: Show + edit: Edit + destroy: Destroy + + attributes: + created_at: Created at + updated_at: Updated at + created: Created %{date} ago + updated: Updated %{date} ago + + activerecord: + models: + user: Contributor + attributes: + user: + login: Id + email: Email + password: Password + lastname: Name + firstname: First name diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 138a9d2e..525a586c 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1,3 +1,25 @@ fr: - hello: "Bonjour le monde" + show: Voir + edit: Éditer + destroy: Supprimer + attributes: + created_at: Créé le + updated_at: Modifié le + created: Créé il y a %{date} + updated: Mis à jour il y a %{date} + + activerecord: + models: + user: Contributeur + attributes: + user: + login: Identifiant + email: Email + password: Mot de passe + lastname: Nom + firstname: Prénom + + layouts: + application: + login: Authentication diff --git a/config/routes.rb b/config/routes.rb index 0e8f8b18..93dfd819 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,8 @@ AgendaDuLibreRails::Application.routes.draw do ActiveAdmin.routes(self) resources :users + root to: 'users#index' + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/db/structure.sql b/db/structure.sql new file mode 100644 index 00000000..5ae923f1 --- /dev/null +++ b/db/structure.sql @@ -0,0 +1,215 @@ +-- MySQL dump 10.13 Distrib 5.5.33, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: adl_fr +-- ------------------------------------------------------ +-- Server version 5.5.33-1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `active_admin_comments` +-- + +DROP TABLE IF EXISTS `active_admin_comments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `active_admin_comments` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `namespace` varchar(255) DEFAULT NULL, + `body` text, + `resource_id` varchar(255) NOT NULL, + `resource_type` varchar(255) NOT NULL, + `author_id` int(11) DEFAULT NULL, + `author_type` varchar(255) DEFAULT NULL, + `created_at` datetime DEFAULT NULL, + `updated_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index_active_admin_comments_on_namespace` (`namespace`), + KEY `index_active_admin_comments_on_author_type_and_author_id` (`author_type`,`author_id`), + KEY `index_active_admin_comments_on_resource_type_and_resource_id` (`resource_type`,`resource_id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `admin_users` +-- + +DROP TABLE IF EXISTS `admin_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `admin_users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `email` varchar(255) NOT NULL DEFAULT '', + `encrypted_password` varchar(255) NOT NULL DEFAULT '', + `reset_password_token` varchar(255) DEFAULT NULL, + `reset_password_sent_at` datetime DEFAULT NULL, + `remember_created_at` datetime DEFAULT NULL, + `sign_in_count` int(11) NOT NULL DEFAULT '0', + `current_sign_in_at` datetime DEFAULT NULL, + `last_sign_in_at` datetime DEFAULT NULL, + `current_sign_in_ip` varchar(255) DEFAULT NULL, + `last_sign_in_ip` varchar(255) DEFAULT NULL, + `created_at` datetime DEFAULT NULL, + `updated_at` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `index_admin_users_on_email` (`email`), + UNIQUE KEY `index_admin_users_on_reset_password_token` (`reset_password_token`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `cities` +-- + +DROP TABLE IF EXISTS `cities`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cities` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `majname` varchar(255) NOT NULL DEFAULT '', + `postalcode` int(11) DEFAULT NULL, + `inseecode` int(11) DEFAULT NULL, + `regioncode` int(11) DEFAULT NULL, + `latitude` float DEFAULT NULL, + `longitude` float DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `cities_name` (`name`) +) ENGINE=MyISAM AUTO_INCREMENT=51637 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `events` +-- + +DROP TABLE IF EXISTS `events`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `events` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL DEFAULT '', + `description` text NOT NULL, + `start_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `end_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `city` varchar(255) NOT NULL DEFAULT '', + `region` int(11) NOT NULL DEFAULT '0', + `locality` int(11) NOT NULL DEFAULT '0', + `url` varchar(255) NOT NULL DEFAULT '', + `contact` varchar(255) NOT NULL DEFAULT '', + `submitter` varchar(255) NOT NULL DEFAULT '', + `moderated` int(11) NOT NULL DEFAULT '0', + `tags` varchar(255) NOT NULL DEFAULT '', + `secret` varchar(255) NOT NULL DEFAULT '', + `decision_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `submission_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `moderator_mail_id` varchar(32) DEFAULT NULL, + `submitter_mail_id` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `events_date` (`start_time`,`end_time`) +) ENGINE=MyISAM AUTO_INCREMENT=8113 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `lugs` +-- + +DROP TABLE IF EXISTS `lugs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lugs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `region` int(11) NOT NULL DEFAULT '0', + `department` int(11) NOT NULL DEFAULT '0', + `name` varchar(255) NOT NULL DEFAULT '', + `url` varchar(255) NOT NULL DEFAULT '', + `city` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=3444 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `notes` +-- + +DROP TABLE IF EXISTS `notes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `notes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `contents` text NOT NULL, + `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `event_id` int(11) DEFAULT NULL, + `author_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=662 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `regions` +-- + +DROP TABLE IF EXISTS `regions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `regions` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migrations` +-- + +DROP TABLE IF EXISTS `schema_migrations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migrations` ( + `version` varchar(255) NOT NULL, + UNIQUE KEY `unique_schema_migrations` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `login` varchar(255) NOT NULL DEFAULT '', + `password` varchar(255) NOT NULL DEFAULT '', + `email` varchar(255) NOT NULL DEFAULT '', + `lastname` varchar(255) NOT NULL DEFAULT '', + `firstname` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2013-11-24 15:40:00 +INSERT INTO schema_migrations (version) VALUES ('0'); + +INSERT INTO schema_migrations (version) VALUES ('20131114103118'); + +INSERT INTO schema_migrations (version) VALUES ('20131114103121'); diff --git a/test/fixtures/admin_users.yml b/test/fixtures/admin_users.yml index 937a0c00..0bf1b515 100644 --- a/test/fixtures/admin_users.yml +++ b/test/fixtures/admin_users.yml @@ -3,9 +3,8 @@ # This model initially had no columns defined. If you add columns to the # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value + +one: + email: one@example.com +two: + email: two@example.com diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 937a0c00..b7503092 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -3,9 +3,9 @@ # This model initially had no columns defined. If you add columns to the # model remove the '{}' from the fixture names and add the columns immediately # below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value + +one: + email: one@example.com + +two: + email: two@example.com