Skip to content
Browse files

Add newsposts

Newsposts are tracked in the database (not that there's a real CMS…),
in the Post and Poster classes. (Not that there's more than one poster
either…)

This finishes up the "lost" page.
  • Loading branch information...
1 parent 376177e commit 0dbebb435570d2c102d20dee832014d8219909cb @mistydemeo committed Aug 11, 2012
View
2 app.rb
@@ -7,6 +7,8 @@
require 'json'
require 'models/items'
+require 'models/post'
+require 'models/poster'
require 'helpers'
require 'preeventualist/brooklynt'
View
16 bin/create_newsposts
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+# This tool just migrates the newsposts into a database
+$: << File.join(__FILE__, "../..")
+$: << File.join(__FILE__, "../lib")
+
+require 'app'
+require "preeventualist/newsposts"
+
+perry = Poster.new
+perry.name = "perry"
+perry.save
+
+Newsposts.each do |contents|
+ post = perry.posts.new contents
+ post.save
+end
View
14 db/migrate/20120812004539_create_posts.rb
@@ -0,0 +1,14 @@
+class CreatePosts < ActiveRecord::Migration
+ def up
+ create_table :posts do |t|
+ t.datetime :created_on
+ t.integer :poster_id
+ t.text :text
+ t.string :salutation
+ end
+ end
+
+ def down
+ drop_table :posts
+ end
+end
View
11 db/migrate/20120812011554_create_posters.rb
@@ -0,0 +1,11 @@
+class CreatePosters < ActiveRecord::Migration
+ def up
+ create_table :posters do |t|
+ t.string :name
+ end
+ end
+
+ def down
+ drop_table :posters
+ end
+end
View
52 lib/preeventualist/newsposts.rb
@@ -0,0 +1,52 @@
+# Used to fill in the newsposts from a script.
+# Not hardly a real CMS, but when every newspost has already been written...
+Newsposts = [
+ {
+ created_on: "15 Nov 2004",
+ text: "preeventualist's day sale. if you lose something today, you get to pick one free
+item (of $40 value or less) from the house of somebody who found something. we're
+having so much fun with this!! this is EXACTLY how i got my rowing machine last year
+and i LOVE IT!!"
+ },
+ {
+ created_on: "23 Feb 2005",
+ text: "i know there's a lot of noise today. stanley bros circus lost twelve llamas and a
+trailer and a bunch of Masterlocks and five tents. they're still finding lost stuff.
+pls keep your heads, i need everyone's help. these entertainers have _nothing_. i
+mean it. i gave a guy a purple sticker today (it's just something i like to do as a
+kind gesture) and he practically slept on it and farmed the ingredients for pizza sauce
+on it. they are on rock bottom.
+
+so please donate. i know we don't have paypal or anything. so if you want to donate,
+just post that you found something (a children's bike, a month of perishable canned
+goods) and that it has the circus people's names written on it or something.",
+ salutation: "great"
+ },
+ {
+ created_on: "25 Feb 2005",
+ text: "server went down at 3 o'clock. i'm mad as you guys. gaff is downstairs and he'll
+be down there until he gets it fixed. :O -- UPDATE: it's fixed, back in bizz!!"
+ },
+ {
+ created_on: "07 April 2005",
+ text: "we're all sifting through the carpet here at hq, but if you could all keep an eye out
+for caitlin's clipboard, she's too quiet of a gal to post it and i know that it's
+REALLY important to her. she had a few really expensive panoramic radiographs of her
+husband's underbite clipped to a few irreplacable photos of her husband in a robocop
+costume back when the underbite was more prominent. she says (to me), \"they'll know
+what i mean when they see them.\" i don't know what that means. :(
+
+i've checked: * the front desk * the hall * the waiting area * the bathroom * the candy
+closet * the big tv area * the lunch counter * the disciples room * gaff's old room
+(the one with the painting of the cherry tree) * the server room * staircase. i'll
+update this as i find more rooms.",
+ salutation: "love"
+ },
+ {
+ created_on: "15 April 2005",
+ text: "hi, big news. we were on channel 8 in wixl and ordish. cory saw it. i was on and
+jerry mathers was on. if you didn't see it, e-mail cory. he tells it the best. all
+i can say is those aren't MY hand motions!! (joke for people who watch channel 8.)
+thanks harry and whole channel 8 news team!!"
+ }
+]
View
14 models/post.rb
@@ -0,0 +1,14 @@
+class Post < ActiveRecord::Base
+ validates_presence_of :text
+ validates_presence_of :poster_id
+ validates_presence_of :created_on
+
+ belongs_to :poster, :class_name => "Poster", :inverse_of => :posts
+
+ def post; <<-EOS
+/ #{created_on.strftime("%d %B %Y")} /
+#{text}
+ - #{salutation+", " if salutation}#{poster.name}
+ EOS
+ end
+end
View
5 models/poster.rb
@@ -0,0 +1,5 @@
+class Poster < ActiveRecord::Base
+ validates_presence_of :name
+
+ has_many :posts, :class_name => "Post", :inverse_of => :poster
+end
View
5 views/lost.erb
@@ -30,6 +30,11 @@
follow. First, a bit of important news from our beloved magistrate. (The kids call
him Uncle Von Guffuncle. Tehe!)
+ IMPORTANT NEWS
+ ==============
+<%= news_string = Post.limit(10).reverse.map(&:post).join("\n").chomp
+ news_string.each_line.map {|l| l.prepend " "}.join %>
+
USING THE L&amp;F SERVER
====================
The L&amp;F is a free service. The acts of losing and finding are essential qualities in

0 comments on commit 0dbebb4

Please sign in to comment.
Something went wrong with that request. Please try again.