Permalink
Browse files

added total_pageviews to pages model, working autocomplete, google ti…

…meline - need to rollback database
  • Loading branch information...
1 parent 00f02fd commit 5405360d1c42d651193a61424f85fb4dd733538f Pete Skomoroch committed Jun 3, 2009
Showing with 1,185 additions and 4 deletions.
  1. +17 −0 README
  2. +2 −0 app/controllers/daily_timelines_controller.rb
  3. +27 −0 app/controllers/pages_controller.rb
  4. +1 −0 app/models/page.rb
  5. +4 −0 app/views/layouts/pages.html.erb
  6. +1 −0 app/views/pages/_search_pane.html.erb
  7. +5 −0 app/views/pages/_search_results.html.erb
  8. +4 −0 app/views/pages/show.html.erb
  9. +4 −1 config/environment.rb
  10. +91 −0 db/data/develop/pages.yml
  11. +1 −0 db/migrate/20090602002800_create_pages.rb
  12. +2 −1 db/schema.rb
  13. +11 −2 lib/sql/preprocess_wikipedia.sql
  14. +8 −0 plugin
  15. +91 −0 test/fixtures/pages.yml
  16. +2 −0 test/fixtures/schema_migrations.yml
  17. +5 −0 vendor/plugins/annotatedtimeline-for-rails/CHANGELOG
  18. +21 −0 vendor/plugins/annotatedtimeline-for-rails/LICENSE
  19. +102 −0 vendor/plugins/annotatedtimeline-for-rails/README
  20. +22 −0 vendor/plugins/annotatedtimeline-for-rails/Rakefile
  21. +2 −0 vendor/plugins/annotatedtimeline-for-rails/init.rb
  22. +1 −0 vendor/plugins/annotatedtimeline-for-rails/install.rb
  23. +192 −0 vendor/plugins/annotatedtimeline-for-rails/lib/annotated_timeline.rb
  24. +4 −0 vendor/plugins/annotatedtimeline-for-rails/tasks/annotated_timeline_tasks.rake
  25. +229 −0 vendor/plugins/annotatedtimeline-for-rails/test/annotated_timeline_test.rb
  26. +31 −0 vendor/plugins/annotatedtimeline-for-rails/test/test_helper.rb
  27. +1 −0 vendor/plugins/annotatedtimeline-for-rails/uninstall.rb
  28. +23 −0 vendor/plugins/auto_complete/README
  29. +22 −0 vendor/plugins/auto_complete/Rakefile
  30. +2 −0 vendor/plugins/auto_complete/init.rb
  31. +47 −0 vendor/plugins/auto_complete/lib/auto_complete.rb
  32. +143 −0 vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb
  33. +67 −0 vendor/plugins/auto_complete/test/auto_complete_test.rb
View
17 README
@@ -1,7 +1,24 @@
+== Mounting Wikistats AWS Public Dataset
+
ec2-run-instances ami-5394733a -k gsg-keypair -t c1.medium -z us-east-1a
ec2-associate-address -i i-ed440b84 174.129.202.23
ec2-attach-volume vol-2455b74d -i i-ed440b84 -d /dev/sdf
# on ec2
mkdir /mnt/wikidata
mount /dev/sdf /mnt/wikidata
+
+--------------
+
+TODO: expand data volume, take snapshot, and send id to AWS
+
+--------------
+
+Plugins to install:
+
+will_paginate
+autocomplete
+gc4r
+annotated-timeline
+
+
@@ -1,6 +1,8 @@
class DailyTimelinesController < ApplicationController
# GET /daily_timelines
# GET /daily_timelines.xml
+
+
def index
@daily_timelines = DailyTimeline.all
@@ -1,6 +1,15 @@
class PagesController < ApplicationController
# GET /pages
# GET /pages.xml
+ protect_from_forgery :only => [:create, :update, :destroy]
+ layout 'pages', :except => [:auto_complete_for_search_query]
+ #use_google_charts
+
+ def auto_complete_for_search_query
+ @pages = Page.title_like params["search"]["query"]
+ render :partial => "search_results"
+ end
+
def index
@pages = Page.all
@@ -15,6 +24,24 @@ def index
def show
@page = Page.find(params[:id])
+ # @data = {
+ # 1.day.ago => { :foo=>123, :bar=>100 },
+ # 2.day.ago => { :foo=>345, :bar=>200 },
+ # 3.day.ago => { :foo=>445, :bar=>120 },
+ # 4.day.ago => { :foo=>425, :bar=>140 },
+ # 5.day.ago => { :foo=>515, :bar=>107 }
+ # }
+
+ rawdates = JSON.parse(@page.daily_timeline.dates)
+ pageviews = JSON.parse(@page.daily_timeline.pageviews)
+
+ @data ={}
+ rawdates.each_with_index do |date, index|
+ @data[DateTime.strptime( date.to_s, "%Y%m%d")] = {:page_views => pageviews[index]}
+ end
+
+ puts @data
+
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @page }
View
@@ -1,3 +1,4 @@
class Page < ActiveRecord::Base
has_one :daily_timeline
+ named_scope :title_like, lambda { |query| { :conditions => ['title like ?', "#{query}%"], :order => '`total_pageviews` DESC', :limit => 20 } }
end
@@ -6,9 +6,13 @@
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Pages: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
+ <%= javascript_include_tag :defaults %>
+
</head>
<body>
+<%= render :partial=>"pages/search_pane" %>
+
<p style="color: green"><%= flash[:notice] %></p>
<%= yield %>
@@ -0,0 +1 @@
+<%= text_field_with_auto_complete :search, :query %>
@@ -0,0 +1,5 @@
+<ul>
+ <% for page in @pages %>
+ <li><%= link_to h(page.title), :controller=>"pages", :action=>"show", :id=>page %></li>
+ <% end %>
+</ul>
@@ -1,3 +1,7 @@
+
+<%= inline_annotated_timeline @data, 600, 400, 'div_id_to_create' %>
+
+
<p>
<b>Url:</b>
<%=h @page.url %>
View
@@ -38,4 +38,7 @@
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
-end
+end
+
+require "will_paginate"
+require 'json'
Oops, something went wrong.

0 comments on commit 5405360

Please sign in to comment.