Skip to content

Commit

Permalink
initial steps to remove spatial_adapter
Browse files Browse the repository at this point in the history
initial stab at sqlite compatibility and spatial_adapter deprecation

passing tests on sqlite now

README and Gemfile cleanup

README login details

tweaked cloudnine install script

updated cloud9 database config

additional install script updates

update to README for cloudnine and cloudnine install script tweaks

added db/schema.rb.example and modified gitignore

readme update

additional install documentation in README
  • Loading branch information
jywarren committed Mar 23, 2016
1 parent aeb9db4 commit 39f55b2
Show file tree
Hide file tree
Showing 21 changed files with 547 additions and 222 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# Ignore bundler config
.bundle

# Ignore the default SQLite database.
db/*.sqlite3

# Ignore all logfiles and tempfiles.
log/*.log
log/*
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ Contributing to PLOTS2

We welcome community contributions to PLOTS2! To install PLOTS2 locally, follow the instructions [in the README.md file](https://github.com/publiclab/plots2#installation).

Learn more about contributing to PLOTS2 or other Public Lab code projects on this page: http://publiclab.org/wiki/contributing-to-public-lab-software
Learn more about contributing to PLOTS2 or other Public Lab code projects on these pages:

* http://publiclab.org/wiki/developers
* http://publiclab.org/wiki/contributing-to-public-lab-software

##Bug reports & troubleshooting

Expand Down
89 changes: 36 additions & 53 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,84 +1,67 @@
source 'https://rubygems.org'
source 'https://rails-assets.org'

ruby '2.1.2'
gem 'rails', '3.2.20'
gem 'rails', '~> 3.2.20'
gem 'passenger'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Database handling
#group :sqlite do
# gem 'sqlite3'
#end
group :mysql do
gem 'mysql2', '~> 0.3.20' # 0.4.3+ causes a version mismatch, apparently, and demands 'activerecord-mysql2-adapter', below
# run with `bundle install --without production` or `bundle install --without mysql` to exclude this
group :mysql, :production do
gem 'mysql2', '~> 0.3.20'
# mysql 0.4.3+ causes a version mismatch, apparently, and demands 'activerecord-mysql2-adapter'
end

# ships with sqlite set up for easy setup during development
# run with `bundle install --without development` or `bundle install --without sqlite` to exclude this
group :sqlite, :development do
gem 'sqlite3'
end
# TODO support postgresql

#group :postgresql do
# gem "activerecord-postgresql-adapter"
#end

# Support composite primary keys
gem 'composite_primary_keys'

# Gems used only for assets and not required
# in production environments by default.
# Gems used only for assets and not required in production environments by default.
group :assets do
# gem 'sass-rails', '~> 3.2.3'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'execjs' # See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
# run with `bundle install --without development` to exclude these
group :development do
gem "nifty-generators"
end

gem 'uglifier', '>= 1.0.3'
# run with `bundle install --without test` to exclude these
group :test do
#gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'test-unit'
gem 'rake'
end

gem 'jquery-rails'
gem 'passenger'
# run with `bundle install --without production` to exclude these
group :production do
gem "scrypt", "~> 1.2.1"
end

gem 'execjs'
gem 'therubyracer'
#gem 'secondbase', '0.5.0'
gem 'rdiscount', '1.6.8'
gem 'composite_primary_keys'
gem 'jquery-rails'
gem 'rdiscount', '1.6.8' # Markdown
gem 'will_paginate', '>= 3.0.6'
gem 'will_paginate-bootstrap', '>= 1.0.1'
gem 'georuby', '2.0'
gem 'geokit-rails'
gem 'spatial_adapter', :git => 'https://github.com/descentintomael/spatial_adapter.git'
gem 'rails_autolink'
gem 'rb-readline'
gem "paperclip", ">= 4.1.1"

gem "nifty-generators", :group => :development
gem "ruby-openid", :require => "openid"
gem "rack-openid"
gem "authlogic", "3.2.0"
#gem "authlogic-oid", :require => "authlogic_openid"
gem "php-serialize", :require => "php_serialize"

gem "scrypt", "~> 1.2.1"

gem 'less-rails', '~> 2.6'

group :development, :test do
#gem 'rspec-rails'
gem 'factory_girl_rails'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

#gem "mocha", :group => :test
104 changes: 53 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
PublicLab.org
======

A complete rewrite of the Public Lab website on a new platform, with a whole new look. Rails, Bootstrap; intended to:

* boast more usable, friendly, but also more powerful interfaces
* simplify and refine common tasks like posting research notes and filtering spam
* enable faster development (based on Ruby on Rails and Twitter's Bootstrap frameworks)
* completely revise and streamline "following" other contributors or specific keywords, with email alerts
* work on tablets, smartphones, and in recent versions of Internet Explorer

###Key new features:

* new simpler/faster note posting form
* vastly improved advanced search
* fast and easy auto-complete search
* faster, nicer wiki revision interface
* revamped integrated subscriptions interface
* events and mailing list info for place wiki pages
* recent notes, wiki pages, and active contributors per topic in page sidebar
* easy tag-based pages
* "follow" and "star" for each page
* new simplified/improved wiki editing form
* sorting and prioritization of notes and pages by popularity metric
The content management system for the Public Lab research community, the plots2 web application is a combination of a group research blog of what we call "research notes," and a wiki.

It features a Bootstrap-based UI and a variety of community and attribution features that help the Public Lab community collaborate on environmental technology design and documentation, as well as community organizing. Originally a Drupal site, it was rewritten in 2012 in Ruby on Rails, and has since extended but not entirely replaced the legacy Drupal data model and database design.

Some key features include:

* a Markdown-based research note and wiki editor
* wiki editing and revision tracking
* tagging and tag-based content organization
* email notification subscriptions for tags and comments
* a barebones search interface
* a user dashboard presenting recent activity


====

##Simple installation with Cloud9

1. If you have a GitHub account, visit https://c9.io and log in with the GitHub button.
2. Fork this repository to your own GitHub account, creating a `yourname/plots2` project.
3. Name your project, then (order important!) choose the **Ruby** template, THEN enter `yourname/plots2` in the "Clone from Git or Mercurial URL" field, and press **Create Workspace**
3. Name your project, then enter `yourname/plots2` in the "Clone from Git or Mercurial URL" field, and press **Create Workspace**
4. In the command line prompt at the bottom of the page, type `./install_cloudnine.sh` and press enter.
5. Enter your username when prompted, and click "Run Project" when it's done.
5. Enter your username when prompted, and run `rails s -b $IP -p $PORT` when it's done.
6. You're done! Go to the URL shown!


====

##Prerequisites
## Prerequisites

### Database

Our production application runs on mysql, but for development, sqlite3 is sufficient.

Recommended; for an Ubuntu/Debian system. Varies slightly for mac/fedora/etc
* Mac OS X: Macs ship with sqlite3 already installed.
* Ubuntu/Debian: `sudo apt-get install sqlite3`
* Fedora/Red Hat/CentOS: `sudo yum install sqlite` -- you may need `sqlite-devel` as well.

Install a database, if necessary. We use mysql -- we're not adverse to others, but this is what we've built it on.

`sudo apt-get install mysql-server`
### Image libraries

Application-specific dependencies:
If you are just developing and don't plan to do work with image uploading, you may not need the following, but otherwise:

`sudo apt-get install bundler libmysqlclient-dev imagemagick ruby-rmagick`
`sudo apt-get install imagemagick ruby-rmagick`


### Ruby

Install rvm for Ruby management (http://rvm.io)

Expand All @@ -60,20 +61,20 @@ Then, use RVM to install version 2.1.2 of Ruby. (v1.9.3+ should also work):

`rvm install 2.1.2`

You'll also need **bower** which is available through NPM. To install NPM, you can run:

`sudo apt-get install npm`
### Gems with Bundler

Ruby dependencies, or Gems, are managed with Bundler.

However, on Ubuntu, you may need to also install the `nodejs-legacy` package, as due to a naming collision, some versions of Ubuntu already have an unrelated package called `node`. To do this, run:
`gem install bundler` - if it's not already installed, but it should be in a basic RVM ruby.

`sudo apt-get install nodejs-legacy`

On Debian Wheezy, you may need instead to:
### Assets with Bower

* Run `sudo apt-get -t wheezy-backports install nodejs` as the `npm` package may not be available.
* Then run `sudo update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100` to make it available under the name `node` -- similarly to what we do for Ubuntu, above.
* Finally, run `curl -0 -L https://www.npmjs.org/install.sh | sudo sh`
You'll also need **bower** which is available through `npm`, part of `node.js`.

[This wiki page from the nodejs repository](https://github.com/nodejs/node-v0.x-archive/wiki/Installing-Node.js-via-package-manager) has comprehensive and up to date installation guides for many systems.

Once NPM is installed, you should be able to run:

`sudo npm install -g bower`
Expand All @@ -83,20 +84,21 @@ Once NPM is installed, you should be able to run:

Installation steps:

1. In the console, download a copy of the source with `git clone https://github.com/publiclab/plots2.git` or `git clone git@github.com:publiclab/plots2.git`.
2. `cd plots2` to enter the new 'plots2' directory.
3. Install gems with `bundle install` from the rails root folder. You may need to run `bundle update` if you have older gems in your environment.
4. Copy and configure `config/database.yml` from `config/database.yml.example`, using a new empty databse you've created. A quick command you could use is: `cp config/database.yml.example config/database.yml`. You can then use your favorite editor to edit the `config/database.yml` file.
5. Grant database creation permissions to your username.
6. Initialize database with `bundle exec rake db:setup`
* if there are any errors, try one of these two fixes:
* run `rake db:migrate`
* OR
* in MySQL, `drop database XXX;` for each database in `config/database.yml` and then try `rake db:setup` again
7. `rake db:seed` to populate it with initial dummy data
8. Install static assets (like external javascript libraries, fonts) with `bower install`
9. Start rails with `bundle exec passenger start` from the Rails root and open http://localhost:3000 in a web browser. (For some, just `passenger start` will work; adding `bundle exec` ensures you're using the version of passenger you just installed with Bundler.) You may use `passenger start -a 0.0.0.0 -p 3000 -d -e production` to run production version and access it via publicly accessibly IP address.
10. Wheeeee!
1. In the console, download a copy of the source with `git clone https://github.com/publiclab/plots2.git`.
2. Enter the new 'plots2' directory with `cd plots2`.
3. Install gems with `bundle install --without production` from the rails root folder, to install the gems you'll need, excluding those needed only in production. You may need to first run `bundle update` if you have older gems in your environment from previous Rails work.
4. Make a copy of `config/database.yml.sqlite.example` and place it at `config/database.yml` -- for development, we've included a prebuilt sqlite database in the `development.db` file, and this example database config is already set up to connect to it. If you are using another database, you can run `bundle exec rake db:setup` to set it up, and `bundle exec rake db:seed` to populate it with initial dummy data.
5. Make a copy of `db/schema.rb.example` and place it at `db/schema.rb`.
6. Install static assets (like external javascript libraries, fonts) with `bower install`
7. Start rails with `passenger start` from the Rails root and open http://localhost:3000 in a web browser.
8. Wheeeee! You're up and running! Log in with test usernames "user", "moderator", or "admin", and password "password".
9. Run `rake test` to confirm that your install is working properly.

### Bundle exec

For some, it will be necessary to prepend your gem-related commands with `bundle exec`, for example `bundle exec passenger start`; adding `bundle exec` ensures you're using the version of passenger you just installed with Bundler. `bundle exec rake db:setup`, `bundle exec rake db:seed` are other examples of where this might be necessary.

****

##Bugs and support

Expand Down
24 changes: 0 additions & 24 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ def publish
end
end

def geocode
if current_user && current_user.username == "warren"
succeeded = 0
failed = 0
if params[:all]
@users = DrupalUsers.locations
elsif params[:name]
@users = DrupalUsers.find_all_by_name params[:name]
else
@users = DrupalUsers.find(:all, :conditions => ["lat = 0.0 AND profile_values.fid = 2 AND profile_values.value != ''"], :include => :drupal_profile_values)
end
@users.each do |user|
if user.geocode
succeeded += 1
else
failed += 1
end
end
render :text => succeeded.to_s+' OK, '+failed.to_s+' failed'
else
prompt_login "Only admins can view that page."
end
end

def ban
if current_user && (current_user.role == "moderator" || current_user.role == "admin")
user = DrupalUsers.find params[:id]
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_tag_subscribers(node)
# include special tid for indiscriminant subscribers who want it all!
all_tag = DrupalTag.find_by_name("everything")
tids += [all_tag.tid,] if all_tag
usertags = TagSelection.find(:all, :conditions => ["tid IN (?) AND following = true",tids])
usertags = TagSelection.where("tid IN (?) AND following = 'true'", tids)
d = {}
usertags.each do |usertag|
# For each row of (user,tag), build a user's tag subscriptions
Expand Down
10 changes: 0 additions & 10 deletions app/models/drupal_content_field_bbox.rb

This file was deleted.

14 changes: 0 additions & 14 deletions app/models/drupal_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class DrupalNode < ActiveRecord::Base
# has_many :drupal_tag, :through => :drupal_node_tag
has_many :drupal_comments, :foreign_key => 'nid', :dependent => :destroy
has_many :drupal_content_type_map, :foreign_key => 'nid', :dependent => :destroy
has_many :drupal_content_field_bboxes, :foreign_key => 'nid'
has_many :drupal_content_field_mappers, :foreign_key => 'nid', :dependent => :destroy
has_many :drupal_content_field_map_editor, :foreign_key => 'nid', :dependent => :destroy

Expand Down Expand Up @@ -381,19 +380,6 @@ def map
self.drupal_content_type_map.last
end

def locations
self.drupal_content_field_bboxes.collect(&:field_bbox_geo)
end

def location
locations = []
self.locations.each do |l|
locations << l if l && l.x && l.y
end
# cheap divide by zero hack
{:x => locations.collect(&:x).sum/(locations.length+0.000001),:y => locations.collect(&:y).sum/(locations.length+0.000001)}
end

def lat
if self.has_power_tag("lat")
self.power_tag("lat").to_f
Expand Down
Loading

0 comments on commit 39f55b2

Please sign in to comment.