Skip to content

Commit

Permalink
Merge branch 'master' into master-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
thatandromeda committed Jan 31, 2020
2 parents 81c1c6f + 0874b96 commit 2a6ab0e
Show file tree
Hide file tree
Showing 80 changed files with 420 additions and 7,226 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
# Ignore rvm config (may vary between environments).
.rvmrc

# Ignore yarn stuff
node_modules/
yarn.lock

# Ignore all logfiles and tempfiles.
log/*
tmp/
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gem 'date_validator'
gem 'devise'
gem 'dotenv-rails'
gem 'flutie'
gem 'high_voltage'
gem 'jquery-placeholder-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
Expand Down Expand Up @@ -58,6 +57,7 @@ group :development do
gem 'bullet'
gem 'derailed'
gem 'memory_profiler'
gem 'web-console'
end

group :development, :test do
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GEM
arel (9.0.0)
bcrypt (3.1.13)
benchmark-ips (2.7.2)
bindex (0.8.1)
bootsnap (1.4.5)
msgpack (~> 1.0)
bootstrap-datepicker-rails (1.8.0.1)
Expand Down Expand Up @@ -198,7 +199,6 @@ GEM
hashdiff (1.0.0)
hashie (3.6.0)
heapy (0.1.4)
high_voltage (3.1.2)
hodel_3000_compliant_logger (0.1.1)
html2haml (2.2.0)
erubis (~> 2.7.0)
Expand Down Expand Up @@ -464,6 +464,11 @@ GEM
vcr (4.0.0)
warden (1.2.7)
rack (>= 1.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down Expand Up @@ -504,7 +509,6 @@ DEPENDENCIES
factory_bot_rails
fakeweb
flutie
high_voltage
jquery-placeholder-rails
jquery-rails
jquery-ui-rails
Expand Down Expand Up @@ -551,6 +555,7 @@ DEPENDENCIES
turnout
uglifier
vcr
web-console
webmock

BUNDLED WITH
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Lumen Database collects and analyzes legal complaints and requests for remov

Automated Submissions and Search Using the API
===========
The main [Lumen Database instance](https://www.lumendatabase.org/) has an API that allows individuals and organizations that receive large numbers of notices to submit them without using the web interface. The API also provides an easy way for researchers to search the database. Members of the public can test the database, but will likely need to request an API key from the [Lumen team](mailto:[email protected]) in order to receive a token that provides full acess. To learn about the capabilities of the API you can consult the [API documentation](https://github.com/berkmancenter/lumendatabase/wiki/Lumen-API-Documentation).
The main [Lumen Database instance](https://www.lumendatabase.org/) has an API that allows individuals and organizations that receive large numbers of notices to submit them without using the web interface. The API also provides an easy way for researchers to search the database. Members of the public can test the database, but will likely need to request an API key from the [Lumen team](mailto:[email protected]) in order to receive a token that provides full access. To learn about the capabilities of the API you can consult the [API documentation](https://github.com/berkmancenter/lumendatabase/wiki/Lumen-API-Documentation).

Development
===========
Expand All @@ -20,7 +20,7 @@ Development
* PostgreSQL 9.6
* Elasticsearch 5.6.x
* Java Runtime Environment (OpenJDK works fine)
* Piwik Tracking
* Piwik Tracking (only used in prod)
* Mail server (SMTP, Sendmail)
* phantomjs (used only by test runner)

Expand Down Expand Up @@ -48,12 +48,18 @@ You can customize behavior during seeding (db:setup) with a couple of environmen
instead of the default 500
* `SKIP_FAKE_DATA=1` will skip generating fake seed data entirely.

#### Admin login
#### Sample user logins

Username: [email protected]
The seed data creates logins of the following form:

Username: {username}@lumendatabase.org
Password: password

If you seeded your database with an older version of `seeds.rb`, your username may be [email protected].
username is one of {user, submitter, redactor, publisher, admin, super_admin},
with corresponding privileges.

If you seeded your database with an older version of `seeds.rb`, your username
may use chillingeffects.org rather than lumendatabase.org.

#### Running Tests

Expand All @@ -74,9 +80,13 @@ their own commit.

* [Skylight](https://www.skylight.io/app/applications/utm46ElcSDtw/recent/5m/endpoints)
* track page rendering time, count allocations, find possibly dodgy SQL
* analytics to help you find the problem areas
* analytics to help you find the problem areas at a high level
* login required
* runs in prod
* [mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler)
* available in dev by default
* in use on prod, visible only to super_admins
* in-depth memory profiling, stacktracing, and SQL queries; good for granular analysis
* [bullet](https://github.com/flyerhzm/bullet)
* find N+1 queries and unused eager loading
* runs in dev
Expand Down Expand Up @@ -151,8 +161,8 @@ The application requires a mail server, in development it's best to use a local
Ephemera
========

The `/blog_entries` page contains a google custom search engine that's supposed
to search the Lumen blog. To enable, create a custom search engine
The `/blog_entries` page can contain a google custom search engine that
searches the Lumen blog. To enable, create a custom search engine
[here](https://www.google.com/cse/create/new) restricted to the path the blog
lives at, for instance `https://www.lumendatabase.org/blog_entries/*`. Extract
the "cx" id from the javascript embed code and put it in the
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/layouts/_application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ section.main.app {
}

// Add inner padding to certain pages
body.topics-show, .high_voltage-pages {
body.topics-show, .static-pages {
.main-inner {
padding: $base-padding;

Expand Down
5 changes: 2 additions & 3 deletions app/assets/stylesheets/pages/_pages.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.high_voltage-pages {
.static-pages {
section.main {
section {
margin-bottom: 30px;
Expand Down Expand Up @@ -31,7 +31,7 @@
}

.collaborations {
.collaboration#partner {
.collaboration#partner {
margin: 0;
height: 500px;
}
Expand Down Expand Up @@ -198,4 +198,3 @@ pre,code,table.codetable {
background-color:#eee;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
}

22 changes: 0 additions & 22 deletions app/controllers/blog_entries_controller.rb

This file was deleted.

40 changes: 40 additions & 0 deletions app/controllers/blog_feed_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class BlogFeedController < ApplicationController
include Comfy::CmsHelper

def index
setup_blog_articles
respond_to do |format|
format.rss { render :layout => false }
end
end

def setup_blog_articles
@blog_articles = []
latest_blog_posts.each do |post|
@blog_articles << articleify(post)
end
end

private

def latest_blog_posts
Comfy::Cms::Page.find_by_label('blog_entries')
.children
.last(10)
.reverse
rescue NoMethodError # when blog_entries undefined, or no children
[]
end

def articleify(post)
OpenStruct.new(
title: cms_fragment_content('title', post),
author: cms_fragment_content('author', post),
pubDate: post.created_at.to_s(:rfc822),
link: post.url,
guid: post.id.to_s,
content: cms_fragment_content('content', post),
description: cms_fragment_content('abstract', post)
)
end
end
11 changes: 10 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ def index
@notices = Rails.cache.fetch(
'newest_notices', expires_in: 1.hour
) { Notice.visible.recent }
@blog_entries = BlogEntry.recent_posts
@blog_entries = blog_entries
end

def blog_entries
Comfy::Cms::Page.find_by_label('blog_entries')
.children
.last(5)
.reverse
rescue NoMethodError # when blog_entries undefined, or no children
nil
end
end
5 changes: 0 additions & 5 deletions app/controllers/original_news_ids_controller.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/helpers/blog_entry_helper.rb

This file was deleted.

14 changes: 14 additions & 0 deletions app/helpers/comfy/comfy_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ def blog_posts(cms_site)
Kaminari.paginate_array(scope.to_a, total_count: scope.count)
.page(params[:page]).per(10)
end

def blog_search_engine_configured?
Chill::Application.config.google_custom_blog_search_id.present?
end

def page_path(label)
Comfy::Cms::Page.find_by_label(label).full_path
# If someone tries to use this on an undefined page, we'll return something
# that will probably 404. That means we will probably notice the page is
# missing, but we won't crash the site -- especially useful in development,
# as localhost may not have a fully defined set of pages.
rescue NoMethodError
"pages/#{label}"
end
end
1 change: 0 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def initialize(user)
can :publish, Notice
can :rescind, Notice
can :create, Notice
can :create, BlogEntry

can :pdf_requests, :all
can :view_full_version, Notice
Expand Down
66 changes: 0 additions & 66 deletions app/models/blog_entry.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/models/blog_entry_topic_assignment.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/notice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class Notice < ApplicationRecord
has_many :topic_assignments, dependent: :destroy
has_many :topics, through: :topic_assignments
has_many :topic_relevant_questions, through: :topics, source: :relevant_questions
has_many :related_blog_entries, -> { distinct }, through: :topics, source: :blog_entries
has_many :entity_notice_roles, dependent: :destroy, inverse_of: :notice
has_many :entities, through: :entity_notice_roles
has_many :file_uploads
Expand Down
3 changes: 0 additions & 3 deletions app/models/topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class Topic < ApplicationRecord
has_many :topic_assignments, dependent: :destroy
has_many :notices, through: :topic_assignments

has_many :blog_entry_topic_assignments, dependent: :destroy
has_many :blog_entries, through: :blog_entry_topic_assignments

has_and_belongs_to_many :relevant_questions
has_and_belongs_to_many :topic_managers

Expand Down
13 changes: 0 additions & 13 deletions app/views/blog_entries/_blog_entry.html.erb

This file was deleted.

Loading

0 comments on commit 2a6ab0e

Please sign in to comment.