diff --git a/Gemfile b/Gemfile index 1cb1085..bf54489 100755 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem 'jquery-rails' # gem 'jbuilder' # Use unicorn as the app server -# gem 'unicorn' + gem 'unicorn' # Deploy with Capistran # gem 'capistrano' diff --git a/app/models/crawlobject.rb b/app/models/crawlobject.rb index 2a94d52..6b24a81 100644 --- a/app/models/crawlobject.rb +++ b/app/models/crawlobject.rb @@ -112,18 +112,18 @@ class Crawlobject < ActiveRecord::Base def json JSON.parse(self.raw) end - def self.crawl_news + def self.crawl_news(id) cfg = Rails.application.config - res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[5]['bin']} #{cfg.crawlconfig[5]['url']}`) + res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[id]['bin']} #{cfg.crawlconfig[id]['url']}`) res.each do |r| cc=Crawlobject.new(:raw=>r.to_json) - cc.objtype=5 + cc.objtype=id cc.parse_object cc.calc_hash - if Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>5).count==0 + if Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>id).count==0 cc.save else - cc = Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>5).first + cc = Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>id).first cc.raw=r.to_json cc.parse_object cc.calc_hash diff --git a/app/models/lva.rb b/app/models/lva.rb index 3e6fe2a..d282ede 100755 --- a/app/models/lva.rb +++ b/app/models/lva.rb @@ -262,7 +262,7 @@ class Lva < ActiveRecord::Base def read_et_forum lva=self url=lva.forumlink - ans = JSON.parse(`python ../microdata/downloadlogin.py #{url}`) + ans = JSON.parse(`python #{Rails.root}/bin/downloadlogin.py #{url}`) ans.each do |a| if Crawlobject.where(:objhash=>Digest::SHA512.hexdigest(a.to_json), :objtype=>1).count ==0 aa = Crawlobject.new(:raw=>a.to_json) diff --git a/app/views/lvas/show.html.erb b/app/views/lvas/show.html.erb index 876783b..ce779ef 100755 --- a/app/views/lvas/show.html.erb +++ b/app/views/lvas/show.html.erb @@ -111,6 +111,9 @@ <%= render 'beispiele/form_bulk' %> + + <% end %> +
<% @crawlobjects.each do |co| %> @@ -119,7 +122,6 @@
- <% end %> diff --git a/app/views/themes/blue1/home/index.html.erb b/app/views/themes/blue1/home/index.html.erb index 53778b6..481b871 100644 --- a/app/views/themes/blue1/home/index.html.erb +++ b/app/views/themes/blue1/home/index.html.erb @@ -44,7 +44,7 @@ <%= render 'beispiele' %> -<% cache("neuigkeiten_startpage_"+ cache_array_key(@neuigkeiten)) do %> +
-<% end %> +
<% cache("calendar_" + cache_array_key(@calentries)+params[:month].to_s+params[:year].to_s) do %> <%= render 'calendars/calentries', :object=>@calentries %> diff --git a/config/schedule.rb b/config/schedule.rb index 0ca81ac..ebec7ff 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -4,3 +4,6 @@ end every 1.day, :at =>'4:00 am' do rake "-s neuigkeit_cache:update" end +every 1.day, :at =>'3:00 am' do + rake "-s crawler:run" +end