-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a database to record tag clouds over time.
Squashed commit of the following: commit 11fe49ef19cab7e63e175f600a2f48d8dbe645f8 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 17:24:38 2009 +0000 title & positioning tweak commit 4ec8014cf3a5abbd7de8be56fae4a586151122b2 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 17:15:38 2009 +0000 store cloud only if text has changed since last time commit 3ab4b6c1762ff6fb82813253a8322f90374edba9 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 15:59:14 2009 +0000 moved cloud text method to a new method on mp commit cd5a5829e3d8f838b76f889e1714e12eba417f6f Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 15:37:00 2009 +0000 added machinist plugin commit a80783d3778e2d078bd9fd2eacfed2a69740d8ee Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 15:33:39 2009 +0000 show mp's last cloud commit 3ea2f9b565b2fc09bc2ff578368977bef9e53210 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 15:33:21 2009 +0000 cloud has terms commit b3bb8d95f4d7f213e15621cf0af92c02248f51c3 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 15:16:52 2009 +0000 renamed word to term commit 567163d1dc3c6ef8d1409cc2202e550b60d60861 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 14:57:23 2009 +0000 refactoring commit 2447d728a2e0ef92a60380775dfc8e06e08dba5a Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 14:45:34 2009 +0000 annotated commit 1fb7535f73ab9cfa7e9a597c0de5b1c802cad7dc Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 14:45:24 2009 +0000 rails *really* doesn't like having a model with an 'instantiate' class method commit 944d1832dfb37b148cd0ce8a9bb8cd6f2e4137ae Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 14:44:50 2009 +0000 mp spec commit 79b48bb4ef3d6622a28511fbc076a1d756d3d027 Author: David Salgado <david@digitalronin.com> Date: Sat Mar 28 14:44:44 2009 +0000 deleted commit 01ee2c605196dbf230b04100b119dc8f9073295a Author: David Salgado <david@digitalronin.com> Date: Mon Mar 23 00:06:21 2009 +0000 Cloud is now an active_record model commit fea3dc644f789a9dab732fe669d49a3d0a2d2de0 Author: David Salgado <david@digitalronin.com> Date: Mon Mar 23 00:00:01 2009 +0000 MP is now an active_record model commit d637e3a734ac23dd027147b55e838e4209fc1b23 Author: David Salgado <david@digitalronin.com> Date: Sun Mar 22 23:51:56 2009 +0000 Converted Word class to ActiveRecord model commit 31bfd8d1cb9c4e8d52183da6a1bbb228c4d70c3f Author: David Salgado <david@digitalronin.com> Date: Sun Mar 22 23:47:57 2009 +0000 fixed broken spec task commit e7a97b032ba867a9e95f6906bf497e6dc3d73dc7 Author: David Salgado <david@digitalronin.com> Date: Sun Mar 22 19:58:00 2009 +0000 added models
- Loading branch information
1 parent
0dc568b
commit 085f908
Showing
38 changed files
with
1,400 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ public/stylesheets/parlour_tag.css | |
public/stylesheets/common.css | ||
public/mps.html | ||
public/mps | ||
db/schema.rb | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||
|
||
def cloud_tag(word) | ||
style = "font-size: #{(word.size_factor * 100).round / 100.0}em;" | ||
style << " color: ##{word.colour};" | ||
style << " left: #{word.x}px;" | ||
style << " top: #{word.y}px" | ||
def cloud_tag(term) | ||
style = "font-size: #{(term.size_factor * 100).round / 100.0}em;" | ||
style << " color: ##{term.colour};" | ||
style << " left: #{term.x}px;" | ||
style << " top: #{term.y}px" | ||
|
||
%[<li class='word' style="#{style}">#{word.text}</li>\n] | ||
%[<li class='term' style="#{style}">#{term.text}</li>\n] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
class Cloud | ||
attr_accessor :title, :words | ||
# == Schema Information | ||
# Schema version: 20090322184246 | ||
# | ||
# Table name: clouds | ||
# | ||
# id :integer(4) not null, primary key | ||
# mp_id :integer(4) | ||
# created_at :datetime | ||
# updated_at :datetime | ||
# | ||
|
||
class Cloud < ActiveRecord::Base | ||
belongs_to :mp | ||
has_many :terms | ||
|
||
def initialize(params) | ||
@mp = params[:mp] | ||
@title = "#{@mp.full_name} Written Questions" | ||
tc = TextChunk.new text | ||
@words = tc.terms_with_counts | ||
super params | ||
tc = TextChunk.new mp.text_for_cloud | ||
self.terms = tc.terms_with_counts | ||
end | ||
|
||
private | ||
|
||
def text | ||
@text ||= @mp.written_answer_text | ||
def title | ||
"#{mp.full_name} Written Questions" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# == Schema Information | ||
# Schema version: 20090322184246 | ||
# | ||
# Table name: terms | ||
# | ||
# id :integer(4) not null, primary key | ||
# text :string(255) | ||
# value :integer(4) | ||
# cloud_id :integer(4) | ||
# created_at :datetime | ||
# updated_at :datetime | ||
# | ||
|
||
class Term < ActiveRecord::Base | ||
include PhraseCoordinates | ||
|
||
belongs_to :cloud | ||
|
||
OFFSET_FROM_TOP = 160 | ||
OFFSET_FROM_LEFT = 10 | ||
|
||
# distance from left in percentages | ||
def x | ||
OFFSET_FROM_LEFT + (coordinates.x * 700).to_i | ||
end | ||
|
||
# distance from top in percentages | ||
def y | ||
OFFSET_FROM_TOP + (coordinates.y * 700).to_i | ||
end | ||
|
||
def colour | ||
phrase_colour | ||
end | ||
|
||
def size_factor | ||
(Math.log(value) / Math.log(3) + 1) * 1.5 | ||
end | ||
|
||
private | ||
|
||
def coordinates | ||
@coordinates ||= phrase_coordinates | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
= cloud_tag term | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class CreateModels < ActiveRecord::Migration | ||
def self.up | ||
|
||
create_table :clouds do |t| | ||
t.integer :mp_id | ||
t.timestamps | ||
end | ||
|
||
create_table :terms do |t| | ||
t.string :text | ||
t.integer :value | ||
t.integer :cloud_id | ||
t.timestamps | ||
end | ||
|
||
create_table :mps do |t| | ||
t.string :full_name | ||
t.integer :person_id | ||
t.string :constituency | ||
t.string :party | ||
t.text :written_questions_text | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :mps | ||
drop_table :terms | ||
drop_table :clouds | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.