<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
<%= yield %>diff --git a/.gitignore b/.gitignore index 4a4d70e..c0f9050 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,11 @@ # ignore al .DS_store files of MAC OSX .DS_Store +<<<<<<< HEAD +*~ +======= # ignore paperclip installation files public/system -.project \ No newline at end of file +.project +>>>>>>> upstream/master diff --git a/Gemfile b/Gemfile index ec2ba7b..3ca0ed4 100644 --- a/Gemfile +++ b/Gemfile @@ -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..698392a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,12 +55,13 @@ GEM 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) + multi_json (1.3.2) orm_adapter (0.0.7) paperclip (3.0.2) activemodel (>= 3.0.0) @@ -104,7 +105,9 @@ 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) @@ -124,6 +127,7 @@ DEPENDENCIES cleditor_rails coffee-rails (~> 3.2.1) devise + execjs jquery-rails json (= 1.6.5) paperclip @@ -131,4 +135,5 @@ DEPENDENCIES rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 + therubyracer uglifier (>= 1.0.3) diff --git a/README b/README new file mode 100644 index 0000000..c8f68c2 --- /dev/null +++ b/README @@ -0,0 +1 @@ +All that's missing is the fork. Heh. \ No newline at end of file diff --git a/app/assets/images/fran.jpg b/app/assets/images/fran.jpg new file mode 100644 index 0000000..fdfda70 Binary files /dev/null and b/app/assets/images/fran.jpg differ diff --git a/app/assets/images/jq6.jpg b/app/assets/images/jq6.jpg new file mode 100644 index 0000000..2dceac4 Binary files /dev/null and b/app/assets/images/jq6.jpg differ diff --git a/app/assets/images/mandi.png b/app/assets/images/mandi.png new file mode 100644 index 0000000..4e990ff Binary files /dev/null and b/app/assets/images/mandi.png 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/application.css b/app/assets/stylesheets/application.css index 50d53e3..92b7de4 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,3 +12,10 @@ *= require cleditor *= require_tree . */ + +html, body { +width: 100%; height: 100%; +} +#imagen{ + max-width: 70%; +} 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/sites.css.scss b/app/assets/stylesheets/sites.css.scss index 682e55c..3b6bd81 100644 --- a/app/assets/stylesheets/sites.css.scss +++ b/app/assets/stylesheets/sites.css.scss @@ -1,3 +1,4 @@ // Place all the styles related to the sites controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..ea2c60c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery + + def doc + end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 0000000..473c6dc --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,87 @@ +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 + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comments } + 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 + + # GET /comments/1/edit + def edit + @comment = Comment.find(params[:id]) + end + + # POST /comments + # POST /comments.json + def create + @comment = Comment.new(params[:comment]) + + respond_to do |format| + if @comment.save + format.html { redirect_to @comment, notice: 'Comment was successfully created.' } + format.json { render json: @comment, status: :created, location: @comment } + else + format.html { render action: "new" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comments/1 + # PUT /comments/1.json + def update + @comment = Comment.find(params[:id]) + + respond_to do |format| + if @comment.update_attributes(params[:comment]) + format.html { redirect_to @comment, notice: 'Comment was successfully updated.' } + 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 + @comment = Comment.find(params[:id]) + @comment.destroy + + respond_to do |format| + format.html { redirect_to comments_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..7816feb 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -29,5 +29,17 @@ def contact # Método que define una acción vacía del controlador def ejemplo end - + + def author + end + # Método que define la acción búsqueda del controlador + def search + if params[:buscar].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:buscar]}%", "%#{params[:buscar]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:buscar]}%", "%#{params[:buscar]}%") + else + render action: "menosdetres" + end + end + end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..5638499 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -22,9 +22,11 @@ def index # GET /sites/1.json def show @site = Site.find(params[:id]) - + @comments = @site.comments.build + respond_to do |format| format.html # show.html.erb + format.js format.json { render json: @site } end end diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..f21a38b 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -80,4 +80,13 @@ def destroy format.json { head :no_content } end end + + def ordered_index + @types = Type.order(:name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + 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..00fb840 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,7 @@ +class Comment < ActiveRecord::Base + belongs_to :user + belongs_to :site + + validates :user_id, :presence => true + #attr_protected :user_id +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..e147387 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -3,8 +3,13 @@ class Site < ActiveRecord::Base belongs_to :user has_many :visits has_many :trips, :through => :visits - has_attached_file :image - + has_attached_file :image, + :styles => { + :thumb => "50x50", + :small => "150x150", + :medium => "200x200" + } + has_many :comments # 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..6d15d11 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ 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/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..b3d6c2e --- /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 %>
+
Coment | +User | +Site | ++ | + | + |
---|---|---|---|---|---|
<%= comment.coment %> | +<%= comment.user_id %> | +<%= comment.site_id %> | +<%= link_to 'Show', comment %> | + <% if comment.user == current_user %> +<%= link_to 'Edit', edit_comment_path(comment) %> | +<%= link_to 'Destroy', comment, confirm: 'Are you sure?', method: :delete %> | + <% end %> +
<%= notice %>
+ ++ Coment: + <%= @comment.coment %> +
+ ++ User: + <%= @comment.user_id %> +
+ ++ Site: + <%= @comment.site_id %> +
+ + +<%= link_to 'Edit', edit_comment_path(@comment) %> | +<%= link_to 'Back', site_path(@comment.site) %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4c9e36..3fc9b27 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,7 +18,14 @@