Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

# ignore al .DS_store files of MAC OSX
.DS_Store
<<<<<<< HEAD
*~
=======

# ignore paperclip installation files
public/system
.project
.project
>>>>>>> upstream/master
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ gem 'paperclip'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

gem 'execjs'
gem 'therubyracer'
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ 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.17.2)
mime-types (1.18)
multi_json (1.1.0)
orm_adapter (0.0.7)
paperclip (2.4.5)
Expand Down Expand Up @@ -95,7 +96,7 @@ GEM
rdoc (3.12)
json (~> 1.4)
sass (3.1.15)
sass-rails (3.2.4)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
Expand All @@ -104,6 +105,8 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
therubyracer (0.9.10)
libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -123,10 +126,12 @@ DEPENDENCIES
cleditor_rails
coffee-rails (~> 3.2.1)
devise
execjs
jquery-rails
paperclip
pg
rails (= 3.2.2)
sass-rails (~> 3.2.3)
sqlite3
therubyracer
uglifier (>= 1.0.3)
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All that's missing is the fork. Heh.
Binary file added app/assets/images/fran.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/jq6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/mandi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/comments.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/comments.css.scss
Original file line number Diff line number Diff line change
@@ -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/
83 changes: 83 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class CommentsController < ApplicationController
# GET /comments
# GET /comments.json
def index
@comments = Comment.all

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
3 changes: 3 additions & 0 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ def contact

def ejemplo
end

def author
end

end
4 changes: 3 additions & 1 deletion app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ 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.json { render json: @site }
Expand Down Expand Up @@ -93,4 +94,5 @@ def destroy
def count_visita
@site.increment!(:visitas)
end

end
9 changes: 9 additions & 0 deletions app/controllers/types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CommentsHelper
end
4 changes: 4 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :site
end
2 changes: 1 addition & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Site < ActiveRecord::Base
has_many :visits
has_many :trips, :through => :visits
has_attached_file :image

has_many :comments

# Debe estar protegido para evitar accesos indeseados
attr_protected :user_id
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>

<ul>
<% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :coment %><br />
<%= f.text_field :coment %>
</div>
<div class="field">
<%= f.label :user_id %><br />
<%= f.number_field :user_id %>
</div>
<div class="field">
<%= f.label :site_id %><br />
<%= f.number_field :site_id %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/comments/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing comment</h1>

<%= render 'form' %>

<%= link_to 'Show', @comment %> |
<%= link_to 'Back', comments_path %>
27 changes: 27 additions & 0 deletions app/views/comments/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1>Listing comments</h1>

<table>
<tr>
<th>Coment</th>
<th>User</th>
<th>Site</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @comments.each do |comment| %>
<tr>
<td><%= comment.coment %></td>
<td><%= comment.user_id %></td>
<td><%= comment.site_id %></td>
<td><%= link_to 'Show', comment %></td>
<td><%= link_to 'Edit', edit_comment_path(comment) if comment.user_id == current_user.id %></td>
<td><%= link_to 'Destroy', comment, confirm: 'Are you sure?', method: :delete if comment.user_id == current_user.id %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Comment', new_comment_path %>
5 changes: 5 additions & 0 deletions app/views/comments/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New comment</h1>

<%= render 'form' %>

<%= link_to 'Back', comments_path %>
20 changes: 20 additions & 0 deletions app/views/comments/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<p id="notice"><%= notice %></p>

<p>
<b>Coment:</b>
<%= @comment.coment %>
</p>

<p>
<b>User:</b>
<%= @comment.user_id %>
</p>

<p>
<b>Site:</b>
<%= @comment.site_id %>
</p>


<%= link_to 'Edit', edit_comment_path(@comment) %> |
<%= link_to 'Back', comments_path %>
21 changes: 16 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,41 @@
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>

<script type="text/javascript"> $(function() { $( "#trip_description" ).cleditor(); }); </script>
<script type="text/javascript">
$(function() {
$( "#trip_description" ).cleditor();
});
</script>

</head>

<body id="planet">
<div id="banner">
<%= image_tag("logo3.png") %>
<%= @page_title || "Planet Travel Site" %><br />
<div class="user"> <% if current_user %> <%= link_to current_user.name, edit_user_registration_path %> | <%= link_to "Sign out", destroy_user_session_path, :method => :delete %> <% else %> <%= link_to "Sign in", new_user_session_path %> <% end %>
<div class="user">
<% if current_user %>
<%= link_to current_user.name,
edit_user_registration_path %> |
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<% else %>
<%= link_to "Sign in", new_user_session_path %>
<% end %>
</div>
</div>
<div id="columns">
<div id="side">
<%= link_to "Home", planet_index_path %><br />
<%= link_to "Tipos", types_path %><br />
<%= link_to "Sitios", sites_path %><br />
<%= link_to "Viajes", trips_path %><br />
<%= link_to "Viajes", trips_path %><br />
<%= link_to "Contact", planet_contact_path %><br />
<%= link_to "Sign up", new_user_registration_path if !current_user %>
</div>
<div id="main">
<p class="notice"><%= notice %></p> <p class="alert"><%= alert %></p>
<p class="notice"><%= notice %></p> <p class="alert"><%= alert %></p>
<%= yield %>
</div>
</div>
</body>
</html>
</html>
16 changes: 16 additions & 0 deletions app/views/planet/author.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>Author</h1>

<p>
<%= image_tag('fran.jpg') %><br>
Name: Francisco Ayala Serrano<br>
Address: Calle Falsa 123, 28001 Madrid<br>
<a href="mailto:f.ayala@alumnos.upm.es">e-mail</a><br>
Curriculum: estudiante de Ingeniería de Telecomunicación.
</p>
<p>
<%= image_tag('mandi.png') %></br>
Name: Jose Francisco Barea López<br>
Address: Calle Falsa 123, 28001 Madrid<br>
<a href="mailto:jf.barea@alumnos.upm.es">e-mail</a><br>
Curriculum: estudiante de Ingeniería de Telecomunicación y pensador.
</p>
Loading