Skip to content
Permalink
Browse files

Pull latest changes from documentcloud/documentcloud:master

  • Loading branch information...
DavidLemayian committed Dec 31, 2018
2 parents d77f05a + ef48fd1 commit d4c8064884ac244f23f3b6ab229e6b183041f023
Showing with 2,064 additions and 113 deletions.
  1. +4 −1 app/actions/document_import.rb
  2. +1 −1 app/actions/reindex_everything.rb
  3. +2 −2 app/controllers/admin_controller.rb
  4. +1 −0 app/controllers/annotations_controller.rb
  5. +6 −0 app/controllers/home_controller.rb
  6. +1 −0 app/controllers/pages_controller.rb
  7. +45 −4 app/controllers/projects_controller.rb
  8. +5 −4 app/models/document.rb
  9. +0 −4 app/views/documents/preview.html.erb
  10. +5 −22 app/views/donate/index.html.erb
  11. +1 −1 app/views/donate/thanks.html.erb
  12. +1 −6 app/views/home/_sidebar.html.erb
  13. +12 −5 app/views/home/privacy.html.erb
  14. +150 −0 app/views/home/terms/_v2.2.html.erb
  15. +5 −1 app/views/home/terms/changelog.yml
  16. +1 −1 app/views/layouts/new.html.erb
  17. +18 −0 app/views/projects/show.html.erb
  18. +0 −2 app/views/search/preview.html.erb
  19. +0 −1 config/cloud_crowd/api/config.yml
  20. +26 −26 config/initializers/omniauth.rb
  21. +1 −3 config/locales/dan.yml
  22. +4 −0 config/locales/eng.yml
  23. +1 −3 config/locales/fra.yml
  24. +2 −3 config/locales/rus.yml
  25. +1 −2 config/locales/spa.yml
  26. +2 −4 config/locales/ukr.yml
  27. +4 −8 config/routes.rb
  28. +1,669 −0 db/dcloud_development_structure.sql
  29. +9 −1 lib/dc/sanitized.rb
  30. +49 −0 lib/dc/statistics.rb
  31. +5 −0 lib/tasks/crowd.rake
  32. +2 −1 lib/tasks/translations.rake
  33. +1 −1 public/javascripts/translations/dan.js
  34. +1 −1 public/javascripts/translations/eng.js
  35. +1 −1 public/javascripts/translations/fra.js
  36. +1 −1 public/javascripts/translations/rus.js
  37. +1 −1 public/javascripts/translations/spa.js
  38. +1 −1 public/javascripts/translations/ukr.js
  39. +16 −1 public/javascripts/ui/workspace/toolbar.js
  40. +9 −0 public/robots.txt
@@ -155,7 +155,6 @@ def process_text
document.id
end


private

def queue_page_text(text, page_number)
@@ -190,6 +189,10 @@ def save_page_text!
def save_page_aspect_ratios!
ids = document.pages.order(:page_number).pluck(:id)

# This is a query which will take a list of pages and aspect ratios
# and update all of the pages in a single query.
#
# Note, the page objects need to all exist for this to work.
query_template = <<-QUERY
UPDATE pages
SET aspect_ratio = input.aspect_ratio
@@ -16,7 +16,7 @@ def process
counter += 1
(sleep(0.25 * counter) and retry) if counter < 5
LifecycleMailer.exception_notification(e,options).deliver_now
outcomes[:failed].push(:id=>doc.id)
outcomes[:failed].push(:id=>document.id)
end
end
Sunspot.commit
@@ -264,7 +264,7 @@ def organization
top_data = @documents.group(:account_id).count.sort_by{|k,v| -v}.first(@top_count).map do |arr|
m = @memberships.where(account_id: arr.first).first
fake_account = Struct.new(:full_name, :email, :slug)
accountish = m.blank? ? fake_account.new("Deleted User", nil, nil) : m.account
accountish = (m.blank? or m.account.nil?) ? fake_account.new("Deleted User", nil, nil) : m.account
[accountish, arr.last]
end
@top_uploaders = Hash[top_data]
@@ -378,7 +378,7 @@ def login_as

# notify when an Admin logs in as a user.
hook_url = DC::SECRETS['slack_webhook']
text = "#{@current_account.full_name} has logged in as #{acc.full_name} (#{acc.email} on #{Rails.env})."
text = "#{@current_account.full_name} (#{@current_account.email}) has logged in as #{acc.full_name} (#{acc.email} on #{Rails.env})."
data = {:payload => {:text => text, :username => "docbot", :icon_emoji => ":doccloud:"}.to_json}
RestClient.post(hook_url, data)

@@ -43,6 +43,7 @@ def show
@exclude_analytics = true
render template: 'annotations/show_embedded', layout: 'new'
else
@include_analytics = true
make_oembeddable(current_annotation) unless current_annotation.section_note?
set_minimal_nav text: 'Read the full document',
xs_text: 'Full document',
@@ -40,6 +40,7 @@ def terms
return not_found unless @version_numbers.include? @version

@canonical_url = terms_url if @version == @current_terms['version']
@include_analytics = true
render layout: 'new', template: "home/terms/show"
end

@@ -48,18 +49,22 @@ def api_terms
return not_found unless @version_numbers.include? @version

@canonical_url = api_terms_url if @version == @current_terms['version']
@include_analytics = true
render layout: 'new', template: "home/api_terms/show"
end

def status
@include_analytics = true
not_found
end

def privacy
@include_analytics = true
render layout: 'new'
end

def faq
@include_analytics = true
render layout: 'new'
end

@@ -98,6 +103,7 @@ def quackbot

end

@include_analytics = true
render layout: 'new'
end

@@ -30,6 +30,7 @@ def show
@exclude_analytics = true
render template: 'pages/show_embedded'
else
@include_analytics = true
make_oembeddable(current_page)
set_minimal_nav text: 'Read the full document',
xs_text: 'Full document',
@@ -1,12 +1,37 @@
class ProjectsController < ApplicationController

before_action :login_required
before_action :login_required, except: :show

READONLY_ACTIONS = [
:index, :documents
:index, :documents, :show
]
before_action :read_only_error, :except => READONLY_ACTIONS if read_only?

def show
# PLEASE BE CAREFUL WITH THIS ACTION
#
# It was intentionally authored in spite of ProjectsController#current_project
# in order to hack around the notion that projects can be public objects
# and not merely objects viewable if you have edit permissions for them.
@project = Project.where(hidden:false).find(params[:id])
return not_found unless @project

respond_to do |format|
format.html do
@organization_id = @project.account.organization_id
render(layout: 'new')
end
format.json do
documents = @project.documents.accessible(current_account, current_organization).select(:id,:slug)
json({
id: @project.slug,
title: @project.title,
documents: documents.first(10000).map{ |document| document.canonical_url(:html) }
}.as_json)
end
end
end

def index
json Project.visible.accessible(current_account)
end
@@ -45,11 +70,27 @@ def remove_documents
end

private

=begin
Okay i want to add a notion of publicness.
The notions that a project has are:
- projects you own
- projects shared with you
The current project is a project you can edit (which you own or have had shared w/ you)
There should be public projects.
Having a list of public projects and integer ids means that folks can enumerate projects
(they already can via search tho) and find groupings of public documents which may reveal
investigations underway.
Need a mechanism to indicate the privacy/publicness of a project.
Really need to overhaul the search index.
=end
def current_project(only_owner=false)
return @current_project if @current_project
base = only_owner ? current_account.projects : Project.accessible(current_account)
@current_project = base.find(params[:id])
end

end
@@ -293,7 +293,8 @@ def self.upload_statistics(type, id)

# Ensure that titles are stripped of trailing whitespace.
def title=(title="Untitled Document")
self[:title] = self.strip title.strip
# Clean the stripped title
self[:title] = CGI.unescape_html(self.strip title.strip)
end

# Save all text assets, including the `combined_page_text`, and the text of
@@ -899,7 +900,7 @@ def self.duplicate(document_ids, account, options={})
def duplicate!(recipient=nil, options={})
Document.transaction do
# Clone the document.
newattrs = attributes.merge({
newattrs = attributes.dup.merge({
:access => PENDING,
:created_at => Time.now,
:updated_at => Time.now
@@ -912,7 +913,7 @@ def duplicate!(recipient=nil, options={})

# Clone the docdata.
if docdata and options['include_docdata']
Docdata.create! document_id: copy_id, data: docdata.data
Docdata.create! document_id: copy_id, data: docdata.data.dup
end

# Clone the associations.
@@ -925,7 +926,7 @@ def duplicate!(recipient=nil, options={})
associations.push project_memberships if options['include_project']
associations.each do |association|
association.each do |model|
model_attrs = model.attributes.merge newattrs
model_attrs = model.attributes.dup.merge newattrs
model_attrs.delete('id')
model.class.create! model_attrs
end
@@ -27,9 +27,5 @@

<%= render(:partial => 'viewer_editing') if @edits_enabled %>

<% if @current_document %>
<%= render partial: 'common/google', locals: { pageview_url: '/documents/show' } %>
<% end %>

</body>
</html>
@@ -4,7 +4,7 @@
<header id="donation-page-header" class="container-md">
<h1>
Support open and truthful journalism.
<mark>Donate to sourceAFRICA.</mark>
<mark>Donate to DocumentCloud.</mark>
</h1>
</header>

@@ -18,31 +18,14 @@
<div class="container-sm">
<% end %>

<%= bootstrap_form_tag url: donate_charge_path, html: {id: 'donation-form'} do |f| %>
<%= hidden_field_tag(:stripe_token) %>
<%= hidden_field_tag(:stripe_email) %>
<%= hidden_field_tag(:donation_amount_cents) %>
<%= hidden_field_tag(:suggested_donation, @suggested_donation) %>
<div id="donation_amounts" class="btn-group" data-toggle="buttons">
<% @donation_levels.each do |amount| %>
<label class="btn btn-secondary">
<input name="donation_amount" id="donation-amount-<%= amount %>" value="<%= amount %>" type="radio" autocomplete="off"> $<%= amount %>
</label>
<% end %>
<label class="sr-only" for="donation_amount">Amount (USD)</label>
<input name="donation_amount_other" id="donation-amount-other" type="tel" class="form-control" placeholder="Other">
</div>
<p><%= f.submit 'Donate!', class: 'btn btn-block btn-success' %></p>
<div id="error_explanation"></div>
<p class="note">You’re making a tax-deductible donation on behalf of sourceAFRICA to our parent non-profit <%= external_link_to 'Code for Africa', 'https://codeforafrica.org/' %>, a <nobr>non profit</nobr> organization.</p>
<% end %>
<iframe src="https://www.muckrock.com/crowdfund/185/embed/" width="100%" height="530px" style="border: none; box-shadow: 2px 2px 2px #00000024; margin: -1em 0 4em 0;"></iframe>

<% if params[:prolix] %>
</div>
<div id="donation-pitch" class="col-12 pull-md-5 col-md-7">
<p class="lead">Journalism starts with the facts. What happened? Can you prove it? Getting to the truth can be hard, and convincing others even harder.</p>
<p>Investigative journalists use sourceAFRICA to sort through piles of primary source documents, find the story, and then publish that evidence for the public. It's been used in some of the most important reporting of the decade, like Oxpecker's <%= external_link_to 'SA\'s Tigers Going Home To China', 'http://oxpeckers.org/2014/01/sas-tigers-going-home-to-china/' %>.</p>
<p>More than <strong><%= link_to "#{ActiveSupport::NumberHelper.number_to_human Document.unrestricted.count, precision: 2} documents", public_search_url, target: '_blank' %></strong> constituting <strong><%= "#{ActiveSupport::NumberHelper.number_to_human Document.unrestricted.sum(:page_count) } pages" %></strong> have been released to the public through sourceAFRICA.</p>
<p>Investigative journalists use DocumentCloud to sort through piles of primary source documents, find the story, and then publish that evidence for the public. It's been used in some of the most important reporting of the decade, like Oxpecker's <%= external_link_to 'SA\'s Tigers Going Home To China', 'http://oxpeckers.org/2014/01/sas-tigers-going-home-to-china/' %>.</p>
<p>More than <strong><%= link_to "#{ActiveSupport::NumberHelper.number_to_human Document.unrestricted.count, precision: 2} documents", public_search_url, target: '_blank' %></strong> constituting <strong><%= "#{ActiveSupport::NumberHelper.number_to_human Document.unrestricted.sum(:page_count) } pages" %></strong> have been released to the public through DocumentCloud.</p>
<p>If you want to support us in our mission to make good, evidence-backed reporting better and easier, <a class="cast-spotlight-link" href="#donation-page-header">please donate</a>! We run lean on grants and donations, and every dollar helps.</p>
</div>
<% end %>
@@ -102,7 +85,7 @@
</div>

<div class="text-center">
<a class="cast-spotlight-link btn btn-success btn-link" href="#donation-page-header">&uarr; Donate to sourceAFRICA!</a>
<a class="cast-spotlight-link btn btn-success btn-link" href="#donation-page-header">&uarr; Donate to DocumentCloud!</a>
</div>

</div>
@@ -13,7 +13,7 @@
</div>

<section class="container-md text-center mt-5">
<p class="lead">Please encourage others to donated to sourceAFRICA!</p>
<p class="lead">Please encourage others to donated to DocumentCloud!</p>
<p>
<a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-text="Support open and truthful journalism. Donate to #sourceAFRICA. I just did!" data-url="https://dc.sourceafrica.net/donate" data-dnt="true" data-show-count="false">Tweet</a>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
@@ -94,12 +94,7 @@
Show your support for great journalism with a donation to sourceAFRICA.<br>
<%= link_to "Read more about donating", donate_path %>
</p>
<div class="text_input first light">
<div class="inner">
<input type="tel" placeholder="Amount ($)" name="amount" id="donation-amount-other" />
</div>
</div>
<p><button type="submit" class="minibutton default">Donate</button></p>
<a href="/donate"><span class="minibutton default">Donate</span></a>
<div id="error_explanation" style="color:red"></div>
<% end %>
</div>

0 comments on commit d4c8064

Please sign in to comment.
You can’t perform that action at this time.