Deze website werkt beter met JavaScript.
Beginscherm
Verkennen
Help
Inloggen
adrianshort
/
apollo
kopie van
https://github.com/adrianshort/apollo.git
Volgen
1
Ster
0
Vork
0
Code
Kwesties
0
Publicaties
0
Wiki
Activiteit
Bladeren bron
Added posts controller; near action to show posts near a point
master
Adrian Short
12 jaren geleden
bovenliggende
72041be422
commit
4c14a86955
8 gewijzigde bestanden
met
toevoegingen van 44
en
0 verwijderingen
Zij-aan-zij weergave
Diff opties
Statistieken weergeven
Download Patch-bestand
Download Diff-bestand
+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
Bestand weergeven
@@ -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
Bestand weergeven
@@ -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
Bestand weergeven
@@ -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
Bestand weergeven
@@ -0,0 +1,2 @@
module PostsHelper
end
+ 11
- 0
app/views/posts/near.html.haml
Bestand weergeven
@@ -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
Bestand weergeven
@@ -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
Bestand weergeven
@@ -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
Bestand weergeven
@@ -0,0 +1,4 @@
require 'test_helper'
class PostsHelperTest < ActionView::TestCase
end
Schrijf
Voorbeeld
Laden…
Annuleren
Opslaan