diff --git a/README.rdoc b/README.rdoc index da8cdde7f..f38480f27 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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 @@ -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 @@ -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. \ No newline at end of file diff --git a/app/controllers/application.rb b/app/controllers/application.rb index c05a26188..24d0abc46 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -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 diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index 7da8765e7..e539dc842 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 505bb2198..de2762d7e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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") # => '
' @@ -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)) @@ -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 @@ -134,9 +138,18 @@ def add_tag_options(text, options) text.gsub("", "
") 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 diff --git a/app/models/activity.rb b/app/models/activity.rb index cc3c5d484..13e76736a 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: activities # diff --git a/app/models/all_person.rb b/app/models/all_person.rb index 99943031c..c2ca4135d 100644 --- a/app/models/all_person.rb +++ b/app/models/all_person.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/blog.rb b/app/models/blog.rb index 10de40e5b..0ad458150 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: blogs # diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 841edfe35..c6aa7308a 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: posts # diff --git a/app/models/comment.rb b/app/models/comment.rb index abc655dc3..8effbff24 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: comments # diff --git a/app/models/communication.rb b/app/models/communication.rb index cbc28ffbb..f5ae15ba4 100644 --- a/app/models/communication.rb +++ b/app/models/communication.rb @@ -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 @@ -17,6 +17,7 @@ # type :string(255) # created_at :datetime # updated_at :datetime +# conversation_id :integer(11) # class Communication < ActiveRecord::Base diff --git a/app/models/connection.rb b/app/models/connection.rb index ae19ae0fe..e924fac8c 100644 --- a/app/models/connection.rb +++ b/app/models/connection.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: connections # diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 2c70bd1fd..9ffabd7fa 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -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 diff --git a/app/models/email_verification.rb b/app/models/email_verification.rb index 5cce50141..28aacbbb5 100644 --- a/app/models/email_verification.rb +++ b/app/models/email_verification.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: email_verifications # diff --git a/app/models/feed.rb b/app/models/feed.rb index ddec35d3e..bdb2a5be9 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: feeds # diff --git a/app/models/forum.rb b/app/models/forum.rb index 6ba6fed5f..69ca89e7d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: forums # diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index f8d61e964..d8cfbefe2 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: posts # diff --git a/app/models/message.rb b/app/models/message.rb index 26e78473b..856794510 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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 @@ -17,6 +17,7 @@ # type :string(255) # created_at :datetime # updated_at :datetime +# conversation_id :integer(11) # class Message < Communication diff --git a/app/models/page_view.rb b/app/models/page_view.rb index 0ed343935..f39801ab5 100644 --- a/app/models/page_view.rb +++ b/app/models/page_view.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: page_views # diff --git a/app/models/person.rb b/app/models/person.rb index 382fefe55..d7efd5687 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: people # diff --git a/app/models/photo.rb b/app/models/photo.rb index 76cece4fb..456d6216e 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: photos # diff --git a/app/models/post.rb b/app/models/post.rb index ba8a082bd..18658f9ea 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: posts # diff --git a/app/models/preference.rb b/app/models/preference.rb index a08e4de1f..614fc5aac 100644 --- a/app/models/preference.rb +++ b/app/models/preference.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: preferences # diff --git a/app/models/topic.rb b/app/models/topic.rb index cb44ba7d8..17e42d9b9 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 26 +# Schema version: 28 # # Table name: topics # diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 79a57b05d..cb851db1a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -65,6 +65,11 @@
Powered by Insoshi open-source social networking platform + <%- unless test? -%> + <%# A tracker to tell us about the activity of Insoshi installs %> + + <%- end -%>
diff --git a/app/views/people/show.html.erb b/app/views/people/show.html.erb index 02ef2774d..32ac33e86 100644 --- a/app/views/people/show.html.erb +++ b/app/views/people/show.html.erb @@ -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' %> diff --git a/config/environment.rb b/config/environment.rb index 9c9e52408..0b2299ec9 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -72,8 +72,8 @@ # Custom gem requirements # config.gem 'mislav-will_paginate', :version => '~> 2.3.2', # :lib => 'will_paginate', - # :source => 'http://gems.github.com' - config.gem 'rdiscount' + # :source => 'http://gems.github.com' + config.gem 'chronic' end # Set INLINEDIR to override default location for ruby_inline directory # The home directory may not be correctly set in an "su"/"sudo" situation diff --git a/config/initializers/custom_requires.rb b/config/initializers/custom_requires.rb index 4da0ded57..c3a285b3d 100644 --- a/config/initializers/custom_requires.rb +++ b/config/initializers/custom_requires.rb @@ -2,7 +2,14 @@ require 'rand' require 'will_paginate' require 'string' -require 'rdiscount' +# Handle RDiscount and BlueCloth in a unified way. +begin + require 'rdiscount' + BlueCloth = RDiscount +rescue LoadError + # Rails loads BlueCloth automatically if present. + nil +end # In some cases autotest interprets the initialization of the UUID generator # as something new, and so just keeps running the tests. diff --git a/spec/views/people/show.html.erb_spec.rb b/spec/views/people/show.html.erb_spec.rb index fee5949b9..2fbb6c4b7 100644 --- a/spec/views/people/show.html.erb_spec.rb +++ b/spec/views/people/show.html.erb_spec.rb @@ -15,8 +15,12 @@ response.should have_tag("h2", /#{@person.name}/) end - it "should have a description rendered by Markdown" do - response.should have_tag("em", "bar") - end - + it "should have a Markdown-ed description if BlueCloth is present" do + begin + BlueCloth.new("used to raise an exeption") + response.should have_tag("em", "bar") + rescue NameError + nil + end + end end