Skip to content
Open
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
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ gem 'rails', '3.1.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

group :development do
gem 'sqlite3'
end
gem 'pg'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
22 changes: 12 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,25 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.3)
coffee-script-source (1.2.0)
erubis (2.7.0)
execjs (1.2.9)
execjs (1.2.13)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.18)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
json (1.6.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.3)
multi_json (1.0.4)
pg (0.12.2)
polyglot (0.3.3)
rack (1.3.5)
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
Expand All @@ -81,9 +82,9 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.11)
rdoc (3.12)
json (~> 1.4)
sass (3.1.10)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
Expand All @@ -93,7 +94,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -102,7 +103,7 @@ GEM
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.31)
uglifier (1.1.0)
uglifier (1.2.1)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

Expand All @@ -113,6 +114,7 @@ DEPENDENCIES
cleditor_rails
coffee-rails (~> 3.1.1)
jquery-rails
pg
rails (= 3.1.3)
sass-rails (~> 3.1.5)
sqlite3
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/viajes.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/viajes.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Viajes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
1 change: 0 additions & 1 deletion app/controllers/selecteds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def create
respond_to do |format|
if @selected.save
format.html { redirect_to @selected.trip, notice: 'Selected was successfully created.' }
format.js
format.json { render json: @selected, status: :created, location: @selected }
else
format.html { render action: "new" }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index
# 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 }
Expand Down
90 changes: 90 additions & 0 deletions app/controllers/viajes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
class ViajesController < ApplicationController
# GET /viajes
# GET /viajes.json
def index
@viajes = Viaje.all(:order => :hour)

respond_to do |format|
format.html # index.html.erb
format.json { render json: @viajes }
end
end

# GET /viajes/1
# GET /viajes/1.json
def show
@viaje = Viaje.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @viaje }
end
end

# GET /viajes/new
# GET /viajes/new.json
def new
@viaje = Viaje.new
@viaje.site_id = params[:id]
@viaje.hour = 0

respond_to do |format|
if @viaje.save
format.html { redirect_to viajes_url, notice: 'Viaje was successfully created.' }
format.json { render json: @viaje }
else
format.html { redirect_to viajes_url, notice: 'Viaje was unsuccessfully created.' }
format.json { render json: @viaje }
end
end
end

# GET /viajes/1/edit
def edit
@viaje = Viaje.find(params[:id])
end

# POST /viajes
# POST /viajes.json
def create
@viaje = Viaje.new(params[:viaje])

respond_to do |format|
if @viaje.save
format.html { redirect_to @viaje, notice: 'Viaje was successfully created.' }
format.json { render json: @viaje, status: :created, location: @viaje }
else
format.html { render action: "new" }
format.json { render json: @viaje.errors, status: :unprocessable_entity }
end
end
end

# PUT /viajes/1
# PUT /viajes/1.json
def update
@viaje = Viaje.find(params[:id])

respond_to do |format|
if @viaje.update_attributes(params[:viaje])
format.html { redirect_to viajes_url, notice: 'Viaje was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @viaje.errors, status: :unprocessable_entity }
end
end
end

# DELETE /viajes/1
# DELETE /viajes/1.json
def destroy
@viaje = Viaje.find(params[:id])
@viaje.destroy

respond_to do |format|
format.html { redirect_to viajes_url }
format.json { head :ok }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/viajes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ViajesHelper
end
2 changes: 1 addition & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Site < ActiveRecord::Base
belongs_to :type
has_many :selected
belongs_to :viaje
end
3 changes: 3 additions & 0 deletions app/models/viaje.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Viaje < ActiveRecord::Base
has_many :sites
end
45 changes: 43 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,52 @@
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>

<script type="text/javascript">
$(function() {
$( "#trip_description" ).cleditor();
$( "#site_description" ).cleditor();
});
</script>
<script type="text/javascript">
var puntos = [];
function mostrarMapa(){
var mylat = 0;
var mylong = 0;

var latlng = new google.maps.LatLng(mylat, mylong);

var myOptions = {
zoom: 25,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var infowindow = new google.maps.InfoWindow();

var marker, i;
var bounds = new google.maps.LatLngBounds ();
for (i = 0; i < puntos.length; i++) {
bounds.extend (new google.maps.LatLng (puntos[i][1], puntos[i][2]));
marker = new google.maps.Marker({
position: new google.maps.LatLng(puntos[i][1], puntos[i][2]),
map: map
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
content = '<div class="googft-info-window" style="font-family: sans-serif; width: 330px; height: auto; overflow-y: auto;"><table><tr><td><img src="/assets/'+puntos[i][4]+'" style="width: 100px; vertical-align: top; margin-right: .5em" /></td><td style="vertical-align:top;"> <h2 class="color: brown">'+puntos[i][0]+'</h2> <p>'+puntos[i][3]+'</p></td></tr></table> </div>';
infowindow.setContent(content);
infowindow.open(map, marker);
}
})(marker, i));
}
map.fitBounds(bounds);

}
</script>
</head>
<body id="planet">
<div id="banner">
Expand All @@ -23,7 +63,8 @@
<%= 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 "Viaje", viajes_path %><br />
<%= link_to "Viajes", trips_path %><br />
<%= link_to "Contact", planet_contact_path %>
</div>
<div id="main">
Expand Down
1 change: 0 additions & 1 deletion app/views/selecteds/create.js.erb

This file was deleted.

4 changes: 3 additions & 1 deletion app/views/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
</td>

<td class="list_actions">
<%= link_to 'Añadir Sitio' , '/viajes/new/'+site.id.to_s,remote: true, class: 'add_viaje' %><br/>
<%= link_to 'Show', site %><br/>
<%= link_to 'Edit', edit_site_path(site) %><br/>
<%= link_to 'Destroy', site,
:confirm => 'Are you sure?',
:method => :delete %>
:method => :delete %><br/>
Times included: <%= Site.count_by_sql("SELECT COUNT (id) FROM selecteds WHERE site_id ="+site.id.to_s)%>
</td>
</tr>
<% end %>
Expand Down
13 changes: 12 additions & 1 deletion app/views/sites/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<h1>New site</h1>

<%= render 'form' %>

<script type="text/javascript">
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(fillFields, errorFunction);
} else {
alert('No está soportada la geolocalización para este navegador.');}
function fillFields(position){
document.getElementById("site_latitude").value = position.coords.latitude;
document.getElementById("site_longitude").value = position.coords.longitude;
}
function errorFunction(pos) { alert('Error!');}

</script>
<%= link_to 'Back', sites_path %>
3 changes: 2 additions & 1 deletion app/views/sites/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= image_tag(@site.image_url, :class => 'site_image') %>

<h3><%= @site.name %></h3>

Times included: <%= Site.count_by_sql("SELECT COUNT (id) FROM selecteds WHERE site_id ="[email protected]_s)%>
<p><%=sanitize @site.description %></p>

<div class="position">
Expand All @@ -22,5 +22,6 @@
</div>

<p />
<%= link_to 'Añadir Sitio', '/viajes/new/'[email protected]_s,remote: true, class: 'add_viaje_show_site' %>
<%= link_to 'Edit', edit_site_path(@site) %> |
<%= link_to 'Back', sites_path %>
8 changes: 5 additions & 3 deletions app/views/trips/_trip.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

<div id="selected">
<table>
<% trip.selecteds.order(:hour).each do |selected| %>
<script type="text/javascript">
puntos.push(["<%=selected.site.name%>",<%= selected.site.latitude %> , <%=selected.site.longitude%>, "<%= selected.site.description %>", "<%=selected.site.image_url%>"]);

</script>
<tr class="<%= cycle('list_line_odd', 'list_line_even') %>">

<td>
Expand All @@ -22,9 +25,8 @@
<%= link_to 'Destroy', selected,
:confirm => 'Are you sure?',
:method => :delete %>

</td>
</tr>
<% end %>
</table>
</div>

8 changes: 6 additions & 2 deletions app/views/trips/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<p id="notice"><%= notice %></p>
<% end %>


<p>
<b>Name:</b>
<%= @trip.name %>
Expand All @@ -24,7 +25,7 @@

<%= render(@trip) %>

<%= form_for(@selected, remote: true) do |f| %>
<%= form_for(@selected) do |f| %>

<%= f.number_field :trip_id, :value => @trip.id, :hidden => true %>
<%= f.collection_select(:site_id,
Expand All @@ -37,11 +38,14 @@
</div>

<br />
<div id="map_canvas" style="width: 80%; height:400px"></div>
<br />


<%= link_to 'Edit', edit_trip_path(@trip) %>
<%= link_to 'Back', trips_path %>

<p />


<script type="text/javascript"> mostrarMapa.call()</script>

Loading