Skip to content

Commit

Permalink
Signed-off-by: akgitcom <aksoft@163.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
akgitcom committed Jul 18, 2012
1 parent 8bca303 commit db4f01d
Show file tree
Hide file tree
Showing 7 changed files with 12,790 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ gem 'jquery-rails'
#gem 'ruby-debug19', :require => 'ruby-debug'
gem 'will_paginate', '~> 3.0.0'
gem 'devise'
gem "cancan"
gem 'cancan'
gem 'nokogiri'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
nokogiri (1.5.5-x86-mingw32)
orm_adapter (0.3.0)
polyglot (0.3.3)
rack (1.4.1)
Expand Down Expand Up @@ -118,6 +119,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
jquery-rails
nokogiri
rails (= 3.2.1)
sass-rails (~> 3.2.3)
sqlite3
Expand Down
33 changes: 30 additions & 3 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class PostsController < ApplicationController
#http_basic_authenticate_with :name => "root", :password => "root", :except => [:index, :show]
before_filter :authenticate_user!, :except => [:show, :index, :tagsearch]
load_and_authorize_resource :except => [:show, :index, :tagsearch]
before_filter :authenticate_user!, :except => [:show, :index, :tagsearch, :iteye]
load_and_authorize_resource :except => [:show, :index, :tagsearch, :iteye]
# GET /posts
# GET /posts.json
def index
Expand All @@ -15,6 +15,34 @@ def index
end
end

def iteye
# Get a Nokogiri::HTML::Document for the page we’re interested in...
require 'nokogiri'
require 'open-uri'
page = params['page']
@sarr = []
# for page in (1..100).to_a do
url = 'http://www.sosoina.com/Search_lei'+page.to_s+'.html'
@doc = Nokogiri::HTML(open(url), nil, "utf-8")
@li = {}
@doc.css('.sr li').each_with_index do |link,i|
if i>5
@li[i] = {:txt => link.content}
end
end
@liarr = []
@doc.css('.sr li').each do |link|
@liarr << link.content
end
@liarr.each_with_index do |la,i|
if i<6
@liarr.shift
end
end
@sarr << @liarr
# end
end

def wap
render :content_type=>"text/vnd.wap.wml", :layout=>false
end
Expand Down Expand Up @@ -106,7 +134,6 @@ def create
@postreset = params[:post]
@postreset["tags_attributes"] = @tag
@post = Post.new(@postreset)
#@post = Post.new(@postreset)

respond_to do |format|
if @post.save
Expand Down
3 changes: 3 additions & 0 deletions app/views/posts/iteye.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

<br>
<%= @sarr.in_groups_of(6) %>
2 changes: 1 addition & 1 deletion app/views/posts/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

<%= render 'form' %>

<%= link_to 'Back', posts_path %>
<%= link_to 'Back', posts_path %>
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


devise_for :users
match '/posts/tagsearch' => 'posts#tagsearch'
match '/posts/iteye' => 'posts#iteye'
match '/posts/tagsearch/params' => 'posts#tagsearch#params'
resources :posts

get "posts/index"
Expand Down
Loading

0 comments on commit db4f01d

Please sign in to comment.