Este sitio web funciona mejor con JavaScript.
Inicio
Explorar
Ayuda
Iniciar sesión
adrianshort
/
apollo
réplica de
https://github.com/adrianshort/apollo.git
Seguir
1
Destacar
0
Fork
0
Código
Incidencias
0
Lanzamientos
0
Wiki
Actividad
Explorar el Código
Added posts controller; near action to show posts near a point
master
Adrian Short
hace 12 años
padre
72041be422
commit
4c14a86955
Se han
modificado 8 ficheros
con
44 adiciones
y
0 borrados
Dividir vista
Opciones de diferencias
Mostrar estadísticas
Descargar archivo de parche
Descargar archivo de diferencias
+3
-0
app/assets/javascripts/posts.js.coffee
+3
-0
app/assets/stylesheets/posts.css.scss
+10
-0
app/controllers/posts_controller.rb
+2
-0
app/helpers/posts_helper.rb
+11
-0
app/views/posts/near.html.haml
+2
-0
config/routes.rb
+9
-0
test/functional/posts_controller_test.rb
+4
-0
test/unit/helpers/posts_helper_test.rb
+ 3
- 0
app/assets/javascripts/posts.js.coffee
Ver fichero
@@ -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
- 0
app/assets/stylesheets/posts.css.scss
Ver fichero
@@ -0,0 +1,3 @@
// Place all the styles related to the posts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
+ 10
- 0
app/controllers/posts_controller.rb
Ver fichero
@@ -0,0 +1,10 @@
class PostsController < ApplicationController
def near
@posts = Post.near(params[:lat].to_f, params[:lng].to_f, params[:radius].to_f)
respond_to do |format|
format.html # near.html.erb
format.json { render json: @posts }
end
end
end
+ 2
- 0
app/helpers/posts_helper.rb
Ver fichero
@@ -0,0 +1,2 @@
module PostsHelper
end
+ 11
- 0
app/views/posts/near.html.haml
Ver fichero
@@ -0,0 +1,11 @@
%h1 Posts#near
%table
- @posts.each do |p|
%tr
%td= link_to p.title, p.url
%td= p.loc['lat']
%td= p.loc['lng']
%td
- unless p.published.nil?
= p.published.strftime("%d %b %Y %H:%M")
+ 2
- 0
config/routes.rb
Ver fichero
@@ -1,4 +1,6 @@
Apollo::Application.routes.draw do
get "posts/near"
resources :feeds do
member do
get 'fetch'
+ 9
- 0
test/functional/posts_controller_test.rb
Ver fichero
@@ -0,0 +1,9 @@
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
test "should get near" do
get :near
assert_response :success
end
end
+ 4
- 0
test/unit/helpers/posts_helper_test.rb
Ver fichero
@@ -0,0 +1,4 @@
require 'test_helper'
class PostsHelperTest < ActionView::TestCase
end
Escribir
Vista previa
Cargando…
Cancelar
Guardar