<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
<%= yield %>diff --git a/:show b/:show new file mode 100644 index 0000000..e69de29 diff --git a/Gemfile b/Gemfile index ec2ba7b..2ab0ce2 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'devise' # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.2.3' + gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes @@ -47,5 +47,7 @@ gem 'paperclip' # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' -gem 'json', '1.6.5' +gem 'execjs' +gem 'therubyracer' +gem 'json', '1.6.5' diff --git a/Gemfile.lock b/Gemfile.lock index fd905dc..8ea5e21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,7 +39,7 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.3.1) + coffee-script-source (1.2.0) devise (2.0.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) @@ -51,21 +51,21 @@ GEM hike (1.2.1) i18n (0.6.0) journey (1.0.3) - jquery-rails (2.0.2) + jquery-rails (2.0.1) railties (>= 3.2.0, < 5.0) thor (~> 0.14) json (1.6.5) + libv8 (3.3.10.4) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.18) - multi_json (1.3.1) + mime-types (1.17.2) + multi_json (1.1.0) orm_adapter (0.0.7) - paperclip (3.0.2) - activemodel (>= 3.0.0) - activerecord (>= 3.0.0) - activesupport (>= 3.0.0) + paperclip (2.4.5) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) cocaine (>= 0.0.2) mime-types pg (0.13.2) @@ -96,7 +96,7 @@ GEM rdoc (3.12) json (~> 1.4) sass (3.1.15) - sass-rails (3.2.5) + sass-rails (3.2.4) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) @@ -104,14 +104,16 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) + therubyracer (0.10.1) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.33) - uglifier (1.2.4) + tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) warden (1.1.1) @@ -124,6 +126,7 @@ DEPENDENCIES cleditor_rails coffee-rails (~> 3.2.1) devise + execjs jquery-rails json (= 1.6.5) paperclip @@ -131,4 +134,5 @@ DEPENDENCIES rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 + therubyracer uglifier (>= 1.0.3) diff --git a/Gemfile.lock~ b/Gemfile.lock~ new file mode 100644 index 0000000..454ca9b --- /dev/null +++ b/Gemfile.lock~ @@ -0,0 +1,138 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.2) + actionpack (= 3.2.2) + mail (~> 2.4.0) + actionpack (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.1) + rack (~> 1.4.0) + rack-cache (~> 1.1) + rack-test (~> 0.6.1) + sprockets (~> 2.1.2) + activemodel (3.2.2) + activesupport (= 3.2.2) + builder (~> 3.0.0) + activerecord (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + activesupport (3.2.2) + i18n (~> 0.6) + multi_json (~> 1.0) + arel (3.0.2) + bcrypt-ruby (3.0.1) + builder (3.0.0) + cleditor_rails (0.0.3) +<<<<<<< HEAD +======= + cocaine (0.2.1) +>>>>>>> planet2012/master + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.2.0) + devise (2.0.4) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + railties (~> 3.1) + warden (~> 1.1.1) + erubis (2.7.0) + execjs (1.3.0) + multi_json (~> 1.0) + hike (1.2.1) + i18n (0.6.0) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.17.2) + multi_json (1.1.0) + orm_adapter (0.0.7) +<<<<<<< HEAD +======= + paperclip (2.4.5) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types + pg (0.13.2) +>>>>>>> planet2012/master + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.2) + actionmailer (= 3.2.2) + actionpack (= 3.2.2) + activerecord (= 3.2.2) + activeresource (= 3.2.2) + activesupport (= 3.2.2) + bundler (~> 1.0) + railties (= 3.2.2) + railties (3.2.2) + actionpack (= 3.2.2) + activesupport (= 3.2.2) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + sass (3.1.15) + sass-rails (3.2.4) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + sprockets (2.1.2) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.5) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.32) + uglifier (1.2.3) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) + warden (1.1.1) + rack (>= 1.0) + +PLATFORMS + ruby + +DEPENDENCIES + cleditor_rails + coffee-rails (~> 3.2.1) + devise + jquery-rails + paperclip + pg + rails (= 3.2.2) + sass-rails (~> 3.2.3) + sqlite3 + uglifier (>= 1.0.3) diff --git a/Gemfile~ b/Gemfile~ new file mode 100644 index 0000000..dabdd2f --- /dev/null +++ b/Gemfile~ @@ -0,0 +1,42 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.2' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +gem 'devise' + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer' + + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails' +gem 'cleditor_rails' + +gem 'paperclip' + +gem 'pg' + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON +# gem 'jbuilder' + +# Use unicorn as the app server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/Rakefile~ b/Rakefile~ new file mode 100644 index 0000000..8d9611e --- /dev/null +++ b/Rakefile~ @@ -0,0 +1,7 @@ +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Planet::Application.load_tasks diff --git a/app/assets/images/Daniel.jpg b/app/assets/images/Daniel.jpg new file mode 100644 index 0000000..ce0bc60 Binary files /dev/null and b/app/assets/images/Daniel.jpg differ diff --git a/app/assets/images/marina.JPG b/app/assets/images/marina.JPG new file mode 100644 index 0000000..f30dee3 Binary files /dev/null and b/app/assets/images/marina.JPG differ diff --git a/app/assets/images/teide.jpg b/app/assets/images/teide.jpg new file mode 100644 index 0000000..ca7aa9f Binary files /dev/null and b/app/assets/images/teide.jpg differ diff --git a/app/assets/images/vilaflor.jpg b/app/assets/images/vilaflor.jpg new file mode 100644 index 0000000..83b2579 Binary files /dev/null and b/app/assets/images/vilaflor.jpg differ diff --git a/app/assets/javascripts/application.js~ b/app/assets/javascripts/application.js~ new file mode 100644 index 0000000..9097d83 --- /dev/null +++ b/app/assets/javascripts/application.js~ @@ -0,0 +1,15 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// +//= require jquery +//= require jquery_ujs +//= require_tree . 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/application.css~ b/app/assets/stylesheets/application.css~ new file mode 100644 index 0000000..3b5cc66 --- /dev/null +++ b/app/assets/stylesheets/application.css~ @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . +*/ diff --git a/app/assets/stylesheets/comments.css.scss b/app/assets/stylesheets/comments.css.scss new file mode 100644 index 0000000..3722c12 --- /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..84c3d81 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -11,7 +11,7 @@ #planet h1 { - font: 150% sans-serif; + font: 150% sans-serif; color: #226; border-bottom: 3px dotted #77d; } @@ -28,12 +28,12 @@ } #site_list .list_image { - width: 60px; - height: 70px; + width: 60px; + height: 70px; } #site_list .list_description { - width: 60%; + width: 60%; } #site_list .list_description dl { @@ -41,9 +41,9 @@ } #site_list .list_description dt { - color: #244; - font-weight: bold; - font-size: larger; +color: #244; +font-weight: bold; +font-size: larger; } #site_list .list_description dd { @@ -51,17 +51,49 @@ } #site_list .list_actions { - font-size: x-small; - text-align: right; + font-size: x-small; + text-align: right; padding-left: 1em; } #site_list .list_line_even { - background: #a8b8f8; + background: #a8b8f8; } #site_list .list_line_odd { - background: #88b0f8; + background: #88b0f8; +} + +/* Styles for comments */ + +#comment_list table tr td { + padding: 5px; + vertical-align: top; +} + + +#comment_list .comment_description { + width: 60%; +} + +#comment_list .comment_description dl { + margin: 0; +} + +#comment_list .comment_description dt { +color: #244; +font-weight: bold; +font-size: small; +} + +#comment_list .comment_description dd { + margin: 0; +} + +#comment_list .comment_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; } @@ -72,7 +104,7 @@ background: #668; padding-top: 10px; padding-bottom: 10px; - border-bottom: 2px solid; + border-bottom: 2px solid; font: small-caps 40px/40px "Times New Roman", serif; color: #bfb; text-align: center; @@ -89,12 +121,17 @@ font-size: small; } +#search { + float: right; /* Ajuste de borde izquierdo */ + color: #bfb; +} + #columns { background: #446; } #main { - margin-left: 9em; /* Ajuste de borde izquierdo */ + margin-left: 9em; /* Ajuste de borde izquierdo */ padding-top: 4ex; padding-left: 2em; background: white; @@ -105,7 +142,7 @@ padding-top: 1em; padding-left: 1em; padding-bottom: 1em; - width: 8em; /* Ajuste de borde izquierdo */ + width: 8em; /* Ajuste de borde izquierdo */ background: #446; } @@ -117,13 +154,13 @@ /* An entry in the store catalog (no utilizados de momento) */ -#planet .entry { +#planet .entry { overflow: auto; margin-top: 1em; border-bottom: 1px dotted #77d; } -#planet .name { +#planet .name { font-size: 120%; font-family: sans-serif; } @@ -143,8 +180,8 @@ } #store .entry p { - margin-top: 0.5em; - margin-bottom: 0.8em; + margin-top: 0.5em; + margin-bottom: 0.8em; } #store .entry .price_line { @@ -156,14 +193,18 @@ position: relative; } -#store .entry .price { +#store .entry .price { color: #44a; font-weight: bold; margin-right: 2em; } - #main .visitas { - text-indent: 70%; + text-indent: 50%; +} + +#main .geo{ + height: 500px; + width :500px; } diff --git a/app/assets/stylesheets/planet.css~ b/app/assets/stylesheets/planet.css~ new file mode 100644 index 0000000..ea64653 --- /dev/null +++ b/app/assets/stylesheets/planet.css~ @@ -0,0 +1,210 @@ +/* Global styles (no utilizados de momento) */ + +#planet #notice { + color: #000; + border: 2px solid red; + padding: 1em; + margin-bottom: 2em; + background-color: #f0f0f0; + font: bold smaller sans-serif; +} + + +#planet h1 { + font: 150% sans-serif; + color: #226; + border-bottom: 3px dotted #77d; +} + +/* Styles for products/index */ + +#site_list table { + border-collapse: collapse; +} + +#site_list table tr td { + padding: 5px; + vertical-align: top; +} + +#site_list .list_image { + width: 60px; + height: 70px; +} + +#site_list .list_description { + width: 60%; +} + +#site_list .list_description dl { + margin: 0; +} + +#site_list .list_description dt { +color: #244; +font-weight: bold; +font-size: larger; +} + +#site_list .list_description dd { + margin: 0; +} + +#site_list .list_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} + +#site_list .list_line_even { + background: #a8b8f8; +} + +#site_list .list_line_odd { + background: #88b0f8; +} + +/* Styles for comments */ + +#comment_list table tr td { + padding: 5px; + vertical-align: top; +} + + +#comment_list .comment_description { + width: 60%; +} + +#comment_list .comment_description dl { + margin: 0; +} + +#comment_list .comment_description dt { +color: #244; +font-weight: bold; +font-size: small; +} + +#comment_list .comment_description dd { + margin: 0; +} + +#comment_list .comment_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} + + +/* START:mainlayout */ +/* Styles for main page */ + +#banner { + background: #668; + padding-top: 10px; + padding-bottom: 10px; + border-bottom: 2px solid; + font: small-caps 40px/40px "Times New Roman", serif; + color: #bfb; + text-align: center; +} + +#banner img { + float: left; + padding-left: 10px; +} + +#banner .user { + float: right; + color: #bfb; + font-size: small; +} + +#search { + float: left; /* Ajuste de borde izquierdo */ + color: #bfb; +} + +#columns { + background: #446; +} + +#main { + margin-left: 9em; /* Ajuste de borde izquierdo */ + padding-top: 4ex; + padding-left: 2em; + background: white; +} + +#side { + float: left; + padding-top: 1em; + padding-left: 1em; + padding-bottom: 1em; + width: 8em; /* Ajuste de borde izquierdo */ + background: #446; +} + +#side a { + color: #bfb; + font-size: small; +} +/* END:mainlayout */ + +/* An entry in the store catalog (no utilizados de momento) */ + +#planet .entry { + overflow: auto; + margin-top: 1em; + border-bottom: 1px dotted #77d; +} + +#planet .name { + font-size: 120%; + font-family: sans-serif; +} + +#store .entry img { + width: 80px; + margin-right: 5px; + margin-bottom: 5px; + float: left; +} + + +#store .entry h3 { + margin-top: 0; + margin-bottom: 2px; + color: #227; +} + +#store .entry p { + margin-top: 0.5em; + margin-bottom: 0.8em; +} + +#store .entry .price_line { + clear: both; + margin-bottom: 0.5em; +} + +#store .entry .add_to_cart { + position: relative; +} + +#store .entry .price { + color: #44a; + font-weight: bold; + margin-right: 2em; +} + +#main .visitas { + text-indent: 50%; +} + +#main .geo{ + height: 500px; + width :500px; +} + diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 0000000..92ee2c4 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,92 @@ +class CommentsController < ApplicationController + + # GET /comments + # GET /comments.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comments = Comment.all + else + @comments = Site.find(params[:site_id]).comments # path: /sites/id/comment + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # GET /comments/1 + # GET /comments/1.json + def show + @comment = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end + + # GET /comments/new + # GET /comments/new.json + def new + @comment = Comment.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + def edit + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + end + + # POST /comments + # POST /comments.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 + + # 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 + + # DELETE /comments/1 + # DELETE /comments/1.json + def destroy + @site = Site.find(params[:site_id]) + @coment = @site.comments.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/comments_controller.rb~ b/app/controllers/comments_controller.rb~ new file mode 100644 index 0000000..92ee2c4 --- /dev/null +++ b/app/controllers/comments_controller.rb~ @@ -0,0 +1,92 @@ +class CommentsController < ApplicationController + + # GET /comments + # GET /comments.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comments = Comment.all + else + @comments = Site.find(params[:site_id]).comments # path: /sites/id/comment + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # GET /comments/1 + # GET /comments/1.json + def show + @comment = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end + + # GET /comments/new + # GET /comments/new.json + def new + @comment = Comment.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + def edit + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + end + + # POST /comments + # POST /comments.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 + + # 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 + + # DELETE /comments/1 + # DELETE /comments/1.json + def destroy + @site = Site.find(params[:site_id]) + @coment = @site.comments.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..0531b02 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -29,5 +29,14 @@ def contact # Método que define una acción vacía del controlador def ejemplo end + + def search + if params[:busqueda].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:busqueda]}%", "%#{params[:busqueda]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:busqueda]}%", "%#{params[:busqueda]}%") + else + render action: "errorSearch" + end + end end diff --git a/app/controllers/planet_controller.rb~ b/app/controllers/planet_controller.rb~ new file mode 100644 index 0000000..40a4728 --- /dev/null +++ b/app/controllers/planet_controller.rb~ @@ -0,0 +1,42 @@ +# 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 +# +class PlanetController < ApplicationController + # Método que define una acción vacía del controlador + def index + end + # Método que define una acción vacía del controlador + def contact + end + # Método que define una acción vacía del controlador + def ejemplo + end + + def search + if params[:busqueda].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + else + render action: "errorSearch" + end + end + +end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..e3fe402 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,16 +1,14 @@ 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 - + # GET /sites # GET /sites.json - def index + def index if params[:type_id].nil? or params[:type_id].empty? - @sites = Site.all # path: /types + @sites = Site.all # path: /types else - @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites end respond_to do |format| format.html # index.html.erb @@ -22,7 +20,7 @@ def index # GET /sites/1.json def show @site = Site.find(params[:id]) - + @site.increment!(:visitas) respond_to do |format| format.html # show.html.erb format.json { render json: @site } @@ -33,7 +31,7 @@ def show # GET /sites/new.json def new @site = current_user.sites.build # crea sitio vacio asociado a current_user - + respond_to do |format| format.html # new.html.erb format.json { render json: @site } @@ -49,7 +47,7 @@ def edit # POST /sites.json def create @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user - + respond_to do |format| if @site.save format.html { redirect_to @site, notice: 'Site was successfully created.' } @@ -65,7 +63,7 @@ def create # PUT /sites/1.json def update @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user - + respond_to do |format| if @site.update_attributes(params[:site]) format.html { redirect_to @site, notice: 'Site was successfully updated.' } @@ -88,9 +86,4 @@ def destroy format.json { head :no_content } end end - - private - def count_visita - @site.increment!(:visitas) - end end diff --git a/app/controllers/sites_controller.rb~ b/app/controllers/sites_controller.rb~ new file mode 100644 index 0000000..497edcd --- /dev/null +++ b/app/controllers/sites_controller.rb~ @@ -0,0 +1,89 @@ +class SitesController < ApplicationController + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /sites + # GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + else + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end + end + + # GET /sites/1 + # GET /sites/1.json + def show + @site = Site.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + end + end + + # GET /sites/new + # GET /sites/new.json + def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end + end + + # GET /sites/1/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /sites + # POST /sites.json + def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PUT /sites/1 + # PUT /sites/1.json + def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 + # DELETE /sites/1.json + def destroy + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + @site.destroy + + respond_to do |format| + format.html { redirect_to sites_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index 321f6e3..b8b9ab7 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -19,7 +19,6 @@ def index def show @trip = Trip.find(params[:id]) @visit = @trip.visits.build - respond_to do |format| format.html # show.html.erb format.json { render json: @trip } diff --git a/app/controllers/trips_controller.rb~ b/app/controllers/trips_controller.rb~ new file mode 100644 index 0000000..d59d03a --- /dev/null +++ b/app/controllers/trips_controller.rb~ @@ -0,0 +1,91 @@ +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /trips + # GET /trips.json + def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end + end + + # GET /trips/1 + # GET /trips/1.json + def show + @trip = Trip.find(params[:id]) +<<<<<<< HEAD +======= + @visit = @trip.visits.build +>>>>>>> planet2012/master + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/new + # GET /trips/new.json + def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/1/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # POST /trips + # POST /trips.json + def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # PUT /trips/1 + # PUT /trips/1.json + def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /trips/1 + # DELETE /trips/1.json + def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..8062c71 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -80,4 +80,18 @@ def destroy format.json { head :no_content } end end + + def ordered_index + 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 # ordered_index.html.erb + format.json { render json: @types } + end + end end diff --git a/app/controllers/types_controller.rb~ b/app/controllers/types_controller.rb~ new file mode 100644 index 0000000..8062c71 --- /dev/null +++ b/app/controllers/types_controller.rb~ @@ -0,0 +1,97 @@ +class TypesController < ApplicationController + # GET /types + # GET /types.json + def index + @types = Type.all + + 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 + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end + end + + # GET /types/new + # GET /types/new.json + def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end + end + + # GET /types/1/edit + def edit + @type = Type.find(params[:id]) + end + + # POST /types + # POST /types.json + def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # PUT /types/1 + # PUT /types/1.json + def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /types/1 + # DELETE /types/1.json + def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end + end + + def ordered_index + 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 # ordered_index.html.erb + format.json { render json: @types } + end + end +end diff --git a/app/controllers/visits_controller.rb~ b/app/controllers/visits_controller.rb~ new file mode 100644 index 0000000..5bd5366 --- /dev/null +++ b/app/controllers/visits_controller.rb~ @@ -0,0 +1,84 @@ +class VisitsController < ApplicationController + # GET /visits + # GET /visits.json + def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end + end + + # GET /visits/1 + # GET /visits/1.json + def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/new + # GET /visits/new.json + def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # POST /visits + # POST /visits.json + def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # PUT /visits/1 + # PUT /visits/1.json + def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /visits/1 + # DELETE /visits/1.json + def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 0000000..0ec9ca5 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..ece23d0 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,6 @@ +class Comment < ActiveRecord::Base + belongs_to :user + belongs_to :site + + attr_protected :user_id +end diff --git a/app/models/comment.rb~ b/app/models/comment.rb~ new file mode 100644 index 0000000..e16f5ae --- /dev/null +++ b/app/models/comment.rb~ @@ -0,0 +1,7 @@ +class Comment < ActiveRecord::Base + + belongs_to :user + belongs_to :site + + attr_protected :user_id +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..a7ba8b9 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,6 +1,7 @@ class Site < ActiveRecord::Base belongs_to :type belongs_to :user + has_many :comments has_many :visits has_many :trips, :through => :visits has_attached_file :image @@ -11,4 +12,6 @@ class Site < ActiveRecord::Base # Se añaden estas definiciones validates :name, :type_id, :presence => true # campo obligatorio + end + diff --git a/app/models/site.rb~ b/app/models/site.rb~ new file mode 100644 index 0000000..1ff5bcf --- /dev/null +++ b/app/models/site.rb~ @@ -0,0 +1,18 @@ +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + has_many :comments + has_many :visits + has_many :trips, :through => :visits + has_attached_file :image + + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se añaden estas definiciones + validates :name, :type_id, :presence => true # campo obligatorio + +end +end + diff --git a/app/models/trip.rb~ b/app/models/trip.rb~ new file mode 100644 index 0000000..df44742 --- /dev/null +++ b/app/models/trip.rb~ @@ -0,0 +1,13 @@ +class Trip < ActiveRecord::Base +<<<<<<< HEAD + belongs_to :user + + attr_protected :user_id +======= + belongs_to :user + has_many :visits + has_many :sites, :through => :visits + + attr_protected :user_id # por seguridad +>>>>>>> planet2012/master +end diff --git a/app/models/type.rb~ b/app/models/type.rb~ new file mode 100644 index 0000000..d966722 --- /dev/null +++ b/app/models/type.rb~ @@ -0,0 +1,15 @@ +class Type < ActiveRecord::Base +<<<<<<< HEAD + has_many :sites + # Se añade esta definición de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo no repetido +======= + has_many :sites + + + # Se añade esta definición de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo único (no repetido) +>>>>>>> planet2012/master +end diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..8383919 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,8 +1,8 @@ class User < ActiveRecord::Base - has_many :sites has_many :trips - + has_many :comments + # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, diff --git a/app/models/user.rb~ b/app/models/user.rb~ new file mode 100644 index 0000000..75ff714 --- /dev/null +++ b/app/models/user.rb~ @@ -0,0 +1,14 @@ +class User < ActiveRecord::Base + has_many :sites + has_many :trips + + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + validates_presence_of :name + + # Setup accessible (or protected) attributes for your model + attr_accessible :name, :email, :password, :password_confirmation, :remember_me +end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..db20f75 --- /dev/null +++ b/app/views/comments/_comment.html.erb @@ -0,0 +1,22 @@ +
+
|
+
+
+ <% if comment.user == current_user %>
+ <%= link_to 'Edit', edit_site_comment_path(comment.site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + |
+
+ <% end %>
+
+
|
+
+
+ <% if comment.user == current_user %>
+ <%= link_to 'Edit', edit_site_comment_path(comment.site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + |
+
+ <% end %>
+
+
|
+
+
|
+
<%= notice %> + + + diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3d2a882..12ef7ed 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -3,7 +3,10 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> <%= devise_error_messages! %> -
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :name %>
+ <%= f.text_field :name %>
<%= f.label :name %>
<%= f.text_field :name %>
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 79a8c31..ee8309c 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -2,8 +2,9 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> +<%= f.label :name %>
+ <%= f.text_field :name %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :name %>
<%= f.text_field :name %>