Skip to content

Commit

Permalink
Merge branch 'master' into master_edge
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Aug 23, 2008
2 parents 2ee4717 + f0fc105 commit 1ddb3f7
Show file tree
Hide file tree
Showing 28 changed files with 134 additions and 51 deletions.
35 changes: 24 additions & 11 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,34 @@ For more detailed information, check out our guide for Installing Git under Git

=== Libraries

You'll need to install FreeImage or some other image processor (such as ImageMagick/RMagick), SQLite, and (optionally) MySQL. Install instructions for all three are easy to find using Google. (If you're installing FreeImage on Windows, this blog post might be helpful: http://www.thewebfellas.com/blog/2008/2/18/imagescience-on-windows-without-the-pain/comments/931#comment-931.)
You'll need to install FreeImage or some other image processor (such as ImageMagick/RMagick) and a database (MySQL or PostgreSQL). Install instructions for these are easy to find using Google. (If you're installing FreeImage on Windows, this blog post might be helpful: http://www.thewebfellas.com/blog/2008/2/18/imagescience-on-windows-without-the-pain/comments/931#comment-931.)

To use Insoshi's search capability, you also need Sphinx. Follow the instructions at http://www.sphinxsearch.com/downloads.html to install Sphinx for your platform. When running Insoshi in a production envinronment, you should also set up a cron job to rotate the search index as described here:

http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/files/DEPLOYMENT_NOTES.html

This currently works only with MySQL due to a bug in Ultrasphinx.

=== Gems

You probably have Rails already, but might not have the others.

$ sudo gem install rails
$ sudo gem install sqlite3-ruby
$ sudo gem install mysql
$ sudo gem install mysql # for mysql support
$ sudo gem install postgres # for postgres support
$ sudo gem install chronic

If you're using FreeImage/ImageScience, you'll also need the image_science gem:

$ sudo gem install image_science

If you want Markdown formatting support you can install either RDiscount (fast but platform-dependent):

$ sudo gem install rdiscount

or BlueCloth (slower but pure Ruby)

$ sudo gem install BlueCloth


== Installing the app
Expand Down Expand Up @@ -93,32 +103,33 @@ Run the following custom install script

$ script/install

The install rake task runs the database migration and performs some additional setup tasks (generate an encryption keypair for password management, creating an admin account, etc.)
The install script runs the database migration and performs some additional setup tasks (generate an encryption keypair for password management, creating an admin account, etc.)

If the install step fails, you may not have properly set up the configuration files.
If the install step fails, you may not have properly set up your database configuration.

Then prepare the test database
Then prepare the test database and run the tests (which are actually RSpec examples in the spec/ directory):

$ rake db:test:prepare
$ rake spec

configure and start the Ultrasphinx daemon for the test runtime
If the tests fail in the Photos controller test, double-check that an image processor is properly installed.

At this point, configure and start the Ultrasphinx daemon for the test runtime

$ rake ultrasphinx:configure RAILS_ENV=test
$ rake ultrasphinx:index RAILS_ENV=test
$ rake ultrasphinx:daemon:start RAILS_ENV=test

and run the tests (which are actually RSpec examples in the spec/ directory):
and re-run the tests

$ rake spec

If the tests fail in the Photos controller test, double-check that an image processor is properly installed.
The search specs detect whether the search daemon is running and weren't performed during the first test run. An initial test run is needed in order to populate the test database for indexing (search specs would fail on an empty database).

To shut down the Ultrasphinx daemon for test

$ rake ultrasphinx:daemon:stop RAILS_ENV=test

(The search specs are written to run only if the daemon is up.)

=== Loading sample data

Now load the sample data
Expand Down Expand Up @@ -167,6 +178,8 @@ Note that there is a minimalist stat tracker that lets us keep track of how many

<%# A tracker to tell us about the activity of Insoshi installs %>

The tracker works by hitting an external URL, so you should comment out this linem if working offline.

== License

See the file LICENSE.
3 changes: 3 additions & 0 deletions app/controllers/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def require_activation

# A tracker to tell us about the activity of Insoshi installs.
def tracker_vars
File.open("identifier", "w") do |f|
f.write UUID.new
end unless File.exist?("identifier")
@tracker_id = File.open("identifier").read rescue nil
@env = ENV['RAILS_ENV']
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index
@results = @search.results
if model == "AllPerson"
# Convert to people so that the routing works.
@results.map!{ |person| Person.find(person)}
@results.map!{ |person| Person.find(person) }
end
end
end
Expand Down
35 changes: 24 additions & 11 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def set_focus_to_id(id)
end

# Display text by sanitizing and formatting.
# The formatting is done by Markdown via the BlueCloth gem.
# The html_options, if present, allow the syntax
# display("foo", :class => "bar")
# => '<p class="bar">foo</p>'
Expand All @@ -79,7 +78,7 @@ def display(text, html_options = nil)
else
tag_opts = nil
end
processed_text = markdown(sanitize(text))
processed_text = format(sanitize(text))
rescue
# Sometimes Markdown throws exceptions, so rescue gracefully.
processed_text = content_tag(:p, sanitize(text))
Expand Down Expand Up @@ -116,12 +115,17 @@ def email_link(person, options = {})
str << link_to_unless_current(action, path, opts)
end

# Return a formatting note (depends on the presence of a Markdown library)
def formatting_note
%(HTML and
#{link_to("Markdown",
"http://daringfireball.net/projects/markdown/basics",
:popup => true)}
supported)
if markdown?
%(HTML and
#{link_to("Markdown",
"http://daringfireball.net/projects/markdown/basics",
:popup => true)}
formatting supported)
else
"HTML formatting supported"
end
end

private
Expand All @@ -134,9 +138,18 @@ def add_tag_options(text, options)
text.gsub("<p>", "<p#{options}>")
end

# Use RDiscount, which is much faster than BlueCloth.
# See, e.g., http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one
def markdown(text)
RDiscount.new(text).to_html
# Format text using BlueCloth (or RDiscount) if available.
def format(text)
text.nil? ? "" : BlueCloth.new(text).to_html
rescue NameError
text
end

# Is a Markdown library present?
def markdown?
BlueCloth.new("")
true
rescue NameError
false
end
end
2 changes: 1 addition & 1 deletion app/models/activity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: activities
#
Expand Down
30 changes: 29 additions & 1 deletion app/models/all_person.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# == Schema Information
# Schema version: 28
#
# Table name: people
#
# id :integer(11) not null, primary key
# email :string(255)
# name :string(255)
# remember_token :string(255)
# crypted_password :string(255)
# description :text
# remember_token_expires_at :datetime
# last_contacted_at :datetime
# last_logged_in_at :datetime
# forum_posts_count :integer(11) default(0), not null
# blog_post_comments_count :integer(11) default(0), not null
# wall_comments_count :integer(11) default(0), not null
# created_at :datetime
# updated_at :datetime
# admin :boolean(1) not null
# deactivated :boolean(1) not null
# connection_notifications :boolean(1) default(TRUE)
# message_notifications :boolean(1) default(TRUE)
# wall_comment_notifications :boolean(1) default(TRUE)
# blog_comment_notifications :boolean(1) default(TRUE)
# email_verified :boolean(1)
#

class AllPerson < Person
is_indexed :fields => [ 'name', 'description' ]
end
end
2 changes: 1 addition & 1 deletion app/models/blog.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: blogs
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/blog_post.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: posts
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: comments
#
Expand Down
5 changes: 3 additions & 2 deletions app/models/communication.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: communications
#
# id :integer(11) not null, primary key
# subject :string(255)
# content :text
# parent_id :string(255)
# parent_id :integer(11)
# sender_id :integer(11)
# recipient_id :integer(11)
# sender_deleted_at :datetime
Expand All @@ -17,6 +17,7 @@
# type :string(255)
# created_at :datetime
# updated_at :datetime
# conversation_id :integer(11)
#

class Communication < ActiveRecord::Base
Expand Down
2 changes: 1 addition & 1 deletion app/models/connection.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: connections
#
Expand Down
8 changes: 8 additions & 0 deletions app/models/conversation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# == Schema Information
# Schema version: 28
#
# Table name: conversations
#
# id :integer(11) not null, primary key
#

class Conversation < ActiveRecord::Base
has_many :messages, :order => :created_at
end
2 changes: 1 addition & 1 deletion app/models/email_verification.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: email_verifications
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/feed.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: feeds
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/forum.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: forums
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/forum_post.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: posts
#
Expand Down
5 changes: 3 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: communications
#
# id :integer(11) not null, primary key
# subject :string(255)
# content :text
# parent_id :string(255)
# parent_id :integer(11)
# sender_id :integer(11)
# recipient_id :integer(11)
# sender_deleted_at :datetime
Expand All @@ -17,6 +17,7 @@
# type :string(255)
# created_at :datetime
# updated_at :datetime
# conversation_id :integer(11)
#

class Message < Communication
Expand Down
2 changes: 1 addition & 1 deletion app/models/page_view.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: page_views
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: people
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/photo.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: photos
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: posts
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/preference.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: preferences
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/topic.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# == Schema Information
# Schema version: 26
# Schema version: 28
#
# Table name: topics
#
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
</p>
<p>Powered by
<a href="http://insoshi.com/">Insoshi open-source social networking platform</a>
<%- unless test? -%>
<%# A tracker to tell us about the activity of Insoshi installs %>
<img src="http://stats.insoshi.com/<%= @tracker_id %>?env=<%= @env %>"
alt="" width="1" height="1" />
<%- end -%>
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/people/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<%- column_div :type => :secondary do -%>
<%= render :partial => 'shared/minifeed' %>
<%- if logged_in? -%>
<%- unless current_person?(@person) -%>
<%= render :partial => 'shared/contacts_preview',
:locals => { :person => @person } %>
<%= render :partial => 'common_contacts' %>
Expand Down
Loading

0 comments on commit 1ddb3f7

Please sign in to comment.