<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
+ <%= yield %> +diff --git a/Gemfile.lock b/Gemfile.lock index fd905dc..37f7d8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.18) - multi_json (1.3.1) + multi_json (1.3.2) orm_adapter (0.0.7) paperclip (3.0.2) activemodel (>= 3.0.0) @@ -104,7 +104,7 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) diff --git a/app/assets/images/almudena.jpg b/app/assets/images/almudena.jpg new file mode 100644 index 0000000..d2e04ec Binary files /dev/null and b/app/assets/images/almudena.jpg differ diff --git a/app/assets/images/carlos.jpg b/app/assets/images/carlos.jpg new file mode 100644 index 0000000..a2a154f Binary files /dev/null and b/app/assets/images/carlos.jpg differ diff --git a/app/assets/images/debod.jpg b/app/assets/images/debod.jpg new file mode 100644 index 0000000..2ab9aa6 Binary files /dev/null and b/app/assets/images/debod.jpg differ diff --git a/app/assets/images/quique.jpg b/app/assets/images/quique.jpg new file mode 100644 index 0000000..e4292d6 Binary files /dev/null and b/app/assets/images/quique.jpg differ diff --git a/app/assets/images/retiro.jpg b/app/assets/images/retiro.jpg new file mode 100644 index 0000000..c02ee70 Binary files /dev/null and b/app/assets/images/retiro.jpg differ diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comments.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/comments.css.scss b/app/assets/stylesheets/comments.css.scss new file mode 100644 index 0000000..e730912 --- /dev/null +++ b/app/assets/stylesheets/comments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css index ead053a..da31419 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -163,7 +163,31 @@ } + #main .visitas { text-indent: 70%; } - +#shortcuts a{ + color: #2c556e; + font-size: 1.3em; +} +#shortcuts a:visited{ + color: #306e2c; + font-size: 1.3em; +} +.user a:visited{ + color: black; +} +.user a{ + color: black; +} +#search{ + position:absolute; + right:0px; + width:300px; + color: black; + font-size: small; +} +#shortcuts{ + +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..462dac2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de la aplicación +# Incluye la lógica de la aplicación +# +# Clase vacía class ApplicationController < ActionController::Base protect_from_forgery end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 0000000..64c9382 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,101 @@ +# == Controlador de Comments +# +# Incluye la lógica de la clase Comments + +class CommentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comments = Comment.all # path: /sites + else + @comments = Site.find(params[:site_id]).comments # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comments } + end + end + # POST /coments + # POST /coments.json + def create + @site = Site.find(params[:site_id]) + @comment = @site.comments.create(params[:comment]) + @comment.user_id = current_user.id + + respond_to do |format| + if @comment.save + format.html { redirect_to @site, notice: 'Comentario creado' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @comment = Comment.new + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + @comment.destroy + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end + end + + # PUT /comments/1 + # PUT /comments/1.json + def update + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + + respond_to do |format| + if @comment.update_attributes(params[:comment]) + format.html { redirect_to @site, notice: 'Comentario actualizado' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + # GET /coments/1/edit + def edit + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..625b352 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,33 +1,31 @@ -# PlanetController ilustra el uso de *RDoc*. La documentación de un proyecto en -# genera en el directorio *proy/doc* en formato Web con -# $proy> rake doc:app -# -# == Algunos comandos de formateo -# -# Tal y como muestra el subitulo anterior, este se define empezando la -# línea con ==. En los títulos debe empezar por =. -# -# Un [ ... ] seguido de texto define una lista titulada, como aquí -# [Clases, Módulos o Métodos] Se documentan con comentarios justo encima de sus definición, como aquí. -# -# Un * o - definen las entradas de una lista itemizada -# * Un URL se define así email[mailto:pepe@ejemplo.com] -# * o así {Pepe Rubio}[mailto:pepe@ejemplo.com] -# -# Un número o letra seguido de punto genera una lista númerada -# 1. + permite generar *negrita*, igual que con HTML -# 2. _ permite generar _cursiva_, igual que con HTML -# 3. * permite generar letra de +teletipo+, igual que con HTML +# == Controlador de Planet # +# Incluye la lógica de la clase Planet class PlanetController < ApplicationController - # Método que define una acción vacía del controlador + # Método para mostrar la página inicial def index end - # Método que define una acción vacía del controlador + # Método para contactar def contact end - # Método que define una acción vacía del controlador + # Método ejemplo def ejemplo end - + + def author + end + + def doc + #render 'doc.html', :layout =>false + redirect_to "/doc/app/index.html" + end + def search + if params[:q].length >= 3 + @search= params[:q] + @sites = Site.where("name like ? or description like ?", "%"+@search+"%", "%"+@search+"%") + @trips = Trip.where("name like ? or description like ?", "%"+@search+"%", "%"+@search+"%") + else + render action: "incorrectsearch" + end + end end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..ff2da63 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,9 +1,13 @@ +# == Controlador de Sites +# +# Incluye la lógica de la clase Sites + class SitesController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe before_filter :authenticate_user!, :except => [ :index, :show ] - after_filter :count_visita, :only => :show - + after_filter :count_visita, :only => :show + # GET /sites # GET /sites.json def index @@ -22,6 +26,7 @@ def index # GET /sites/1.json def show @site = Site.find(params[:id]) + respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index 321f6e3..ea9d305 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Trips +# +# Incluye la lógica de la clase Trips + class TripsController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..846bc57 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Types +# +# Incluye la lógica de la clase Types + class TypesController < ApplicationController # GET /types # GET /types.json @@ -9,7 +13,16 @@ def index format.json { render json: @types } end end + # GET /types/ordered_index + # GET /types/ordered_index.json + def ordered_index + @types = Type.find(:all, :order => :name) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end # GET /types/1 # GET /types/1.json def show @@ -80,4 +93,6 @@ def destroy format.json { head :no_content } end end + + end diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb index 5bd5366..ecd76ca 100644 --- a/app/controllers/visits_controller.rb +++ b/app/controllers/visits_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Visits +# +# Incluye la lógica de la clase Visits + class VisitsController < ApplicationController # GET /visits # GET /visits.json diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..42e8f0d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Application +# Se encarga de apoyar a la clase Application module ApplicationHelper end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 0000000..65de912 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,4 @@ +# == Helper de Comments +# Se encarga de apoyar a la clase Comments +module CommentsHelper +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..a4437c4 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Planet +# Se encarga de apoyar a la clase Planet module PlanetHelper end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb index 621069d..1b8a208 100644 --- a/app/helpers/sites_helper.rb +++ b/app/helpers/sites_helper.rb @@ -1,2 +1,5 @@ +# == Helper de Sites +# Se encarga de apoyar a la clase Sites + module SitesHelper end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb index 04f333d..a7be91f 100644 --- a/app/helpers/trips_helper.rb +++ b/app/helpers/trips_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Trips +# Se encarga de apoyar a la clase Trips module TripsHelper end diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rb index 40a2b9e..775c75e 100644 --- a/app/helpers/types_helper.rb +++ b/app/helpers/types_helper.rb @@ -1,2 +1,5 @@ +# == Helper de Types +# Se encarga de apoyar a la clase Types + module TypesHelper end diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb index 8ce5f83..fc4b3b4 100644 --- a/app/helpers/visits_helper.rb +++ b/app/helpers/visits_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Visits +# Se encarga de apoyar a la clase Visits module VisitsHelper end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..070eaeb --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,8 @@ +class Comment < ActiveRecord::Base + #Los comentarios son de los usuarios + belongs_to :user + #Y de los sitios + belongs_to :site + + validates :coment, :presence => true, :length => {:maximum => 240} +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..ba540a7 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -4,7 +4,9 @@ class Site < ActiveRecord::Base has_many :visits has_many :trips, :through => :visits has_attached_file :image - + #Tiene varios comentarios + has_many :comments,:dependent => :destroy + has_attached_file :image # Debe estar protegido para evitar accesos indeseados attr_protected :user_id diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..9890bc6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,6 +2,7 @@ class User < ActiveRecord::Base has_many :sites has_many :trips + has_many :comments, :dependent => :destroy # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..07b5f21 --- /dev/null +++ b/app/views/comments/_comment.html.erb @@ -0,0 +1,14 @@ +
+ + <%= comment.user.name if comment.user %> + <%= comment.coment %> +
+ ++ <% if (comment.user == current_user) %> + <%= link_to 'Edit', edit_site_comment_path(@site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
\ No newline at end of file diff --git a/app/views/comments/_edit.html.erb b/app/views/comments/_edit.html.erb new file mode 100644 index 0000000..10b677c --- /dev/null +++ b/app/views/comments/_edit.html.erb @@ -0,0 +1,8 @@ +<%= form_for([@site, @comment]) do |f| %> +| Comment | +User | ++ | + | + |
|---|---|---|---|---|
|
+ |
+ + + <% if comment.user ==current_user %> + | <%= link_to 'Edit', site_comment_path(@site) %> | +<%= link_to 'Destroy', @site.comment, confirm: 'Are you sure?', method: :delete %> | + <% end %> + + +
+ + <%= comment.user.name if comment.user %> + <%= comment.coment %> +
+ ++ <% if (comment.user == current_user) %> + <%= link_to 'Edit', edit_site_comment_path(@site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4c9e36..248e3e7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,7 +6,11 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - + @@ -14,21 +18,67 @@ + + +diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb new file mode 100644 index 0000000..2937e6b --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1,30 @@ +
+
+Nombre: Carlos Crespo González
+Dirección postal: c/Bravo Murillo 333, 2ºD
+Código postal: 28020
+E-mail: carlos.crespog@gmail.com
+<%= image_tag("carlos.jpg") %>
+Breve currículum:
+
+
+ +
+Nombre: Enrique García Navalón
+Dirección postal: c/ Paseo de la Castellana 110, 4ºC
+Código postal: 28018
+E-mail: garcianavalon@gmail.com
+<%= image_tag("quique.jpg") %>
+Breve currículum:
+
+
\ No newline at end of file
diff --git a/app/views/planet/doc.html b/app/views/planet/doc.html
new file mode 120000
index 0000000..930501a
--- /dev/null
+++ b/app/views/planet/doc.html
@@ -0,0 +1 @@
+/Users/carloscrespog/Documents/SWCM/planet2012/doc/app/index.html
\ No newline at end of file
diff --git a/app/views/planet/incorrectsearch.html.erb b/app/views/planet/incorrectsearch.html.erb
new file mode 100644
index 0000000..d2542ab
--- /dev/null
+++ b/app/views/planet/incorrectsearch.html.erb
@@ -0,0 +1,6 @@
+
+
+Ooooooooooooops! parece que ha habido un problema con tu búsqueda, vigile que el número de caracteres introducido sea mayor que 3
+
+
+
\ No newline at end of file
diff --git a/app/views/planet/search.html.erb b/app/views/planet/search.html.erb
new file mode 100644
index 0000000..a0d92e2
--- /dev/null
+++ b/app/views/planet/search.html.erb
@@ -0,0 +1,9 @@
+
+ +<%= render 'sites/sitelist' %> + +<%= @sites.length %><%=" Results found."%> + +<%= render 'trips/triplist' %> + +<%= @trips.length %><%=" Results found."%> \ No newline at end of file diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index f1fd754..3cf68d0 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -1,3 +1,4 @@ + <%= form_for(@site) do |f| %> <% if @site.errors.any? %>
+
+
+ +
+
+ + + +
+
diff --git a/app/views/sites/_geolocalizacion.html.erb b/app/views/sites/_geolocalizacion.html.erb new file mode 100644 index 0000000..a2c67f7 --- /dev/null +++ b/app/views/sites/_geolocalizacion.html.erb @@ -0,0 +1,43 @@ + + +
+ + + + + +
+ +