Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
Browse files Browse the repository at this point in the history
…ssue_4099
  • Loading branch information
zz9pzza committed Nov 6, 2014
2 parents 8be49cf + fc2934d commit fdecc60
Show file tree
Hide file tree
Showing 118 changed files with 1,968 additions and 2,369 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ env:
- TEST_GROUP="cucumber -f progress -r features features/comments_and_kudos"
- TEST_GROUP="cucumber -f progress -r features features/gift_exchanges"
- TEST_GROUP="cucumber -f progress -r features features/importing"
- TEST_GROUP="cucumber -f progress -r features features/other"
- TEST_GROUP="cucumber -f progress -r features features/prompt_memes"
- TEST_GROUP="cucumber -f progress -r features features/other_a"
- TEST_GROUP="cucumber -f progress -r features features/other_b"
- TEST_GROUP="cucumber -f progress -r features features/prompt_memes_a"
- TEST_GROUP="cucumber -f progress -r features features/prompt_memes_b"
- TEST_GROUP="cucumber -f progress -r features features/tags_and_wrangling"
- TEST_GROUP="cucumber -f progress -r features features/users"
- TEST_GROUP="cucumber -f progress -r features features/works"
Expand All @@ -25,12 +27,8 @@ script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec $TEST_GROUP
before_script:
- mysql -e 'create database otwarchive_test;'
- cp config/database.travis.yml config/database.yml
- cp config/newrelic.example config/newrelic.yml
- cp config/redis-cucumber.conf.example config/redis-cucumber.conf
- cp config/redis.travis.example config/redis.yml
- curl -L https://gist.githubusercontent.com/scottsds/8fda6f6fbc66d3a2315e/raw/1d4b990f7922e388d6d7563b9e5cda7c97af18a7/gistfile1.sh | bash
- bash script/travis_configure.sh
- bash script/travis_elasticsearch_upgrade.sh
after_script:
- bundle exec rake coveralls:push
notifications:
Expand Down
12 changes: 7 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ gem 'paperclip'
gem 'fastimage'

gem 'authlogic'
gem 'bcrypt'

# A highly updated version of the authorization plugin
gem 'permit_yo'
Expand Down Expand Up @@ -83,17 +84,18 @@ gem "rack-dev-mark"
#Phrase-app
gem 'phrase'

# Place the New Relic gem as low in the list as possible, allowing the
# frameworks above it to be instrumented when the gem initializes.
gem 'newrelic_rpm', "3.8.0.218"
gem 'newrelic-redis'

# For URL mangling
gem 'addressable'

# For controlling application behavour dynamically
gem 'rollout'

# Place the New Relic gem as low in the list as possible, allowing the
# frameworks above it to be instrumented when the gem initializes.
gem 'newrelic_rpm', "3.9.3.241"
gem 'newrelic-redis'


group :test do
gem 'rspec-rails', '>=2.6.0'
gem 'pickle'
Expand Down
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ GEM
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt (3.1.7)
best_in_place (2.1.0)
jquery-rails
rails (~> 3.1)
Expand Down Expand Up @@ -179,7 +180,7 @@ GEM
newrelic-redis (1.4.0)
newrelic_rpm (~> 3.0)
redis (< 4.0)
newrelic_rpm (3.8.0.218)
newrelic_rpm (3.9.3.241)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
nokogiri (1.6.0-x86-mingw32)
Expand Down Expand Up @@ -356,6 +357,7 @@ DEPENDENCIES
akismetor
authlogic
aws-sdk
bcrypt
best_in_place
bundler
capistrano-gitflow_version (>= 0.0.3)
Expand Down Expand Up @@ -383,7 +385,7 @@ DEPENDENCIES
memcache-client
mysql2
newrelic-redis
newrelic_rpm (= 3.8.0.218)
newrelic_rpm (= 3.9.3.241)
nokogiri (>= 1.4.2)
paperclip
permit_yo
Expand Down
60 changes: 25 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
[![Build Status](https://travis-ci.org/otwcode/otwarchive.png)](https://travis-ci.org/otwcode/otwarchive)
[![Coverage Status](https://coveralls.io/repos/otwcode/otwarchive/badge.png)](https://coveralls.io/r/otwcode/otwarchive)

[![Codeship Status](https://www.codeship.io/projects/1f7468f0-7e15-0131-c059-7a8d26daf885/status?branch=master)](https://www.codeship.io/projects/14476)

## About OTW-Archive
OTW-Archive [![Build Status](https://travis-ci.org/otwcode/otwarchive.png)](https://travis-ci.org/otwcode/otwarchive) [![Coverage Status](https://coveralls.io/repos/otwcode/otwarchive/badge.png)](https://coveralls.io/r/otwcode/otwarchive) [![Codeship Status](https://www.codeship.io/projects/1f7468f0-7e15-0131-c059-7a8d26daf885/status?branch=master)](https://www.codeship.io/projects/14476)
=========

The OTW-Archive software is an open-source web application intended for hosting archives
of fanworks, including fanfic, fanart, and fan vids. Its development is sponsored by
the Organization for Transformative Works (http://transformativeworks.org), a nonprofit
of fanworks, including fanfic, fanart, and fan vids.

Its development is sponsored by
the [Organization for Transformative Works](http://transformativeworks.org), a nonprofit
organization by and for fans.

The OTW-Archive software is still in development and has not yet been released, but you
can see it in action on the Archive of Our Own (http://archiveofourown.org, aka AO3), a
Release Status
---------

The OTW-Archive software is still in beta and has not yet been formally released, but you
can see it in action on the [Archive of Our Own](http://archiveofourown.org), aka AO3, a
multifandom archive also run by the OTW.

Our ultimate goal is to release OTW-Archive in a form that can be installed and used by
any fan archivist who wants to create her own archive. You can get more information about
our broad development plan at the OTW-Archive Roadmap:
http://transformativeworks.org/projects/archive.

Volunteers are always welcome both for coding and testing! Please contact us at:
http://transformativeworks.org/contact/volunteers%20and%20recruiting for full details, or
browse the Github pages (https://github.com/otwcode/otwarchive/wiki).
any fan archivist interested in creating and maintaining a fanwork archive.

## Description of Contents
You can get more information about
our broad development plan at the [OTW-Archive Roadmap](http://transformativeworks.org/projects/archive).

OTW-Archive is built using the Ruby on Rails framework, and uses the standard structure of a
Rails application. A few specific details are described here:
How to Contribute
----------

app
Most of the code specific to this application lives under the app/ directory, organized
into models (which represent the underlying objects in the database), views (which are the
front end of the application), and controllers (which provide the glue).
Volunteers are always welcome both for coding and testing!

Works in the archive (eg, individual fanfic stories) are represented by the files:
models/work.rb, controllers/works_controller.rb, and views/works.
[Read more about volunteering with the OTW](http://transformativeworks.org/how-you-can-help/volunteer) or [drop us an email](mailto:otw-coders@transformativeworks.org) if you have any questions.

Users in the archive are represented by the files:
models/user.rb, controllers/users_controller.rb, and views/users.
You can also submit a pull request; we'll get back to you as soon as we can!

Most metadata in the archive (fandoms, characters, etc) is represented as tags:
models/tag.rb, controllers/tags_controller.rb, views/tags
* Bug Tracking: https://code.google.com/p/otwarchive/issues/list
* Developer Documentation: https://github.com/otwcode/otwarchive/wiki
* Beta Website: http://archiveofourown.org

public
You can find the stylesheets, javascript, help files, and images used in this application
under the public/ directory.
License
----------

db
The overall archive database layout can be found in the file schema.rb
Code is licensed under [GPL](http://www.gnu.org/licenses/gpl-2.0.html) by the [Organization for Transformative Works](http://transformativeworks.org).
9 changes: 0 additions & 9 deletions app/controllers/abuse_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ def create
end
end

def index
@abuse_reports = AbuseReport.by_date.paginate(:page => params[:page])
end

def show
@abuse_report = AbuseReport.find(params[:id])
end

protected

def build_post_info(report)
Expand All @@ -65,5 +57,4 @@ def build_post_info(report)
post_info << "</bug>"
return post_info
end

end
3 changes: 2 additions & 1 deletion app/controllers/chapters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def show
end
@chapter = @work.chapters.find_by_id(params[:id])
unless @chapter
raise ActiveRecord::RecordNotFound, "Couldn't find the chapter '#{params[:id]}' belonging to work '#{params[:work_id]}'"
flash[:error] = ts("Sorry, we couldn't find the chapter you were looking for.")
redirect_to work_path(@work) and return
end
@chapters = @work.chapters_in_order(false)
if !logged_in? || !current_user.is_author_of?(@work)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def find_parent
# Check to see if the ultimate_parent is a Work, and if so, if it's restricted
def check_if_restricted
parent = find_parent
if parent.respond_to?(:restricted) && parent.restricted? && !logged_in?
if parent.respond_to?(:restricted) && parent.restricted? && ! (logged_in? || logged_in_as_admin?)
redirect_to login_path(:restricted_commenting => true) and return
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def new
def create
@user = User.find_by_login(params[:login]) || User.find_by_email(params[:login])
if @user.nil?
raise ActiveRecord::RecordNotFound, "Couldn't find user with username or email '#{params[:login]}'"
flash[:notice] = ts("We couldn't find an account with that email address or username. Please try again?")
render :action => "new"
elsif !@user.active?
flash.now[:error] = ts("Your account has not been activated. Please check your email (including your spam folder) for the activation link or <a href=\"#{new_feedback_report_url}\">contact Support</a>.".html_safe)
render :action => "new"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pseuds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def show
@page_subtitle = @pseud.name

# very similar to show under users - if you change something here, change it there too
if current_user.nil?
if !(logged_in? || logged_in_as_admin?)
# hahaha omg so ugly BUT IT WORKS :P
@fandoms = Fandom.select("tags.*, count(tags.id) as work_count").
joins(:direct_filter_taggings).
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ def index
# GET /users/1
def show
if @user.blank?
raise ActiveRecord::RecordNotFound, "Couldn't find user '#{params[:id]}'"
flash[:error] = ts("Sorry, could not find this user.")
redirect_to people_path and return
end
@page_subtitle = @user.login

# very similar to show under pseuds - if you change something here, change it there too
if current_user.nil?
if !(logged_in? || logged_in_as_admin?)
# hahaha omg so ugly BUT IT WORKS :P
@fandoms = Fandom.select("tags.*, count(tags.id) as work_count").
joins(:direct_filter_taggings).
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def update
@preview_mode = true
if @work.has_required_tags? && @work.invalid_tags.blank?
unless @work.posted?
flash[:notice] = ts('Draft was successfully created. It will be <strong>automatically deleted</strong> on %{deletion_date}', :deletion_date => view_context.time_in_zone(@work.created_at + 1.month)).html_safe
flash[:notice] = ts('Your changes have not been saved. Please post your work or save without posting if you want to keep them.')
end
in_moderated_collection
@chapter = @work.chapters.first unless @chapter
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/challenge_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def prompt_tags(prompt)
details = content_tag(:h6, ts("Tags"), :class => "landmark heading")
TagSet::TAG_TYPES.each do |type|
if prompt && prompt.tag_set && !prompt.tag_set.with_type(type).empty?
details += content_tag(:ul, tag_link_list(prompt.tag_set.with_type(type), link_to_works=true), :title => type, :class => "#{type} type tags commas")
details += content_tag(:ul, tag_link_list(prompt.tag_set.with_type(type), link_to_works=true), :class => "#{type} type tags commas")
end
end
details
Expand Down
8 changes: 7 additions & 1 deletion app/models/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ class Admin < ActiveRecord::Base
# Authlogic gem
acts_as_authentic do |config|
config.transition_from_restful_authentication = true
config.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha1
if (ArchiveConfig.BCRYPT || "true") == "true" then
config.crypto_provider = Authlogic::CryptoProviders::BCrypt
config.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512, Authlogic::CryptoProviders::Sha1]
else
config.crypto_provider = Authlogic::CryptoProviders::Sha512
config.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha1]
end
end

has_many :log_items
Expand Down
5 changes: 3 additions & 2 deletions app/models/story_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,12 @@ def download_from_lj(location)
url.gsub!('_', '-') # convert underscores in usernames to hyphens
url += "?format=light" # go to light format
text = download_with_timeout(url)

if text.match(/adult_check/)
Timeout::timeout(STORY_DOWNLOAD_TIMEOUT) {
begin
agent = Mechanize.new
form = agent.get(url).forms.first
url.include?("dreamwidth") ? form = agent.get(url).forms.first : form = agent.get(url).forms.fourth
page = agent.submit(form, form.buttons.first) # submits the adult concepts form
text = page.body.force_encoding(agent.page.encoding)
rescue
Expand Down Expand Up @@ -584,7 +585,7 @@ def parse_story_from_lj(story)
work_params[:title].gsub! /^[^:]+: /, ""
work_params.merge!(scan_text_for_meta(storytext))

date = @doc.css("span.b-singlepost-author-date")
date = @doc.css("time.b-singlepost-author-date")
unless date.empty?
work_params[:revised_at] = convert_revised_at(date.first.inner_text)
end
Expand Down
25 changes: 0 additions & 25 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,31 +352,6 @@ def async(method, *args)
# Class methods


# Get tags that are either above or below the average popularity
def self.with_popularity_relative_to_average(options = {})
options.reverse_merge!({:factor => 1, :include_meta => false, :greater_than => false, :names_only => false})
comparison = "<"
comparison = ">" if options[:greater_than]

if options[:include_meta]
tags = select("#{options[:names_only] ? "tags.name" : "tags.*"}, filter_counts.unhidden_works_count as count").
joins(:filter_count).
where(:canonical => true).
where("filter_counts.unhidden_works_count #{comparison} (select avg(unhidden_works_count) from filter_counts) * ?", options[:factor]).
order("count ASC")
else
meta_tag_ids = select("DISTINCT tags.id").joins(:sub_taggings).where(:canonical => true)
non_meta_ids = meta_tag_ids.empty? ? select("tags.id").where(:canonical => true) : select("tags.id").where(:canonical => true).where("id NOT IN (#{meta_tag_ids.collect(&:id).join(',')})")
tags = non_meta_ids.empty? ? [] :
select("#{options[:names_only] ? "tags.name" : "tags.*"}, filter_counts.unhidden_works_count as count").
joins(:filter_count).
where(:canonical => true).
where("tags.id IN (#{non_meta_ids.collect(&:id).join(',')})").
where("filter_counts.unhidden_works_count #{comparison} (select AVG(unhidden_works_count) from filter_counts where filter_id in (#{non_meta_ids.collect(&:id).join(',')})) * ?", options[:factor]).
order("count ASC")
end
end

def self.in_prompt_restriction(restriction)
joins("INNER JOIN set_taggings ON set_taggings.tag_id = tags.id
INNER JOIN tag_sets ON tag_sets.id = set_taggings.tag_set_id
Expand Down
8 changes: 7 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ class User < ActiveRecord::Base
# Authlogic gem
acts_as_authentic do |config|
config.transition_from_restful_authentication = true
config.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha1
if (ArchiveConfig.BCRYPT || "true") == "true" then
config.crypto_provider = Authlogic::CryptoProviders::BCrypt
config.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512, Authlogic::CryptoProviders::Sha1]
else
config.crypto_provider = Authlogic::CryptoProviders::Sha512
config.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha1]
end
config.validates_length_of_password_field_options = {:on => :update,
:minimum => ArchiveConfig.PASSWORD_LENGTH_MIN,
:if => :has_no_credentials?}
Expand Down
5 changes: 0 additions & 5 deletions app/views/abuse_reports/_abuse_report.html.erb

This file was deleted.

39 changes: 0 additions & 39 deletions app/views/abuse_reports/index.html.erb

This file was deleted.

Loading

0 comments on commit fdecc60

Please sign in to comment.