This website works better with JavaScript.
首頁
探索
說明
登入
adrianshort
/
apollo
镜像来自
https://github.com/adrianshort/apollo.git
關註
1
收藏
0
複製
0
程式碼
問題管理
0
版本發佈
0
Wiki
Activity
瀏覽代碼
Added posts controller; near action to show posts near a point
master
Adrian Short
12 年之前
父節點
72041be422
當前提交
4c14a86955
共有
8 個文件被更改
,包括
44 次插入
和
0 次删除
分割檢視
Diff Options
Show Stats
Download Patch File
Download Diff File
+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
查看文件
@@ -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
查看文件
@@ -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
查看文件
@@ -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
查看文件
@@ -0,0 +1,2 @@
module PostsHelper
end
+ 11
- 0
app/views/posts/near.html.haml
查看文件
@@ -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
查看文件
@@ -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
查看文件
@@ -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
查看文件
@@ -0,0 +1,4 @@
require 'test_helper'
class PostsHelperTest < ActionView::TestCase
end
Write
Preview
Loading…
取消
儲存