Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
Nudging the repository back into it's current state after epic rebasi…
Browse files Browse the repository at this point in the history
…ng. A representation of the repository's history is mostly preserved, apologies if there are any errors or omissions.
  • Loading branch information
knowtheory committed Nov 30, 2011
1 parent 5cdb92e commit 0991724
Show file tree
Hide file tree
Showing 41 changed files with 303 additions and 292 deletions.
2 changes: 1 addition & 1 deletion app/controllers/accounts_controller.rb
Expand Up @@ -46,7 +46,7 @@ def logged_in
# Creating a new account creates a pending account, with a security key
# instead of a password.
def create
return forbidden unless current_account.admin?
return forbidden unless current_account.admin? or params[:role] == Account::REVIEWER
attributes = pick(params, :first_name, :last_name, :email, :role)
account = Account.lookup(attributes[:email])
if account.nil?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -141,7 +141,7 @@ def server_error(e)
# Simple HTTP Basic Auth to make sure folks don't snoop where the shouldn't.
def bouncer
authenticate_or_request_with_http_basic("DocumentCloud") do |login, password|
login == 'guest' && password == SECRETS['guest_password']
login == SECRETS['guest_username'] && password == SECRETS['guest_password']
end
end

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/documents_controller.rb
Expand Up @@ -210,7 +210,11 @@ def search
end

def preview
render :action => 'show'
return unless login_required
doc = current_document(true)
return forbidden if doc.nil? && Document.exists?(params[:id].to_i)
return not_found unless doc
@options = params[:options]
end


Expand Down
2 changes: 1 addition & 1 deletion app/models/page.rb
Expand Up @@ -5,7 +5,7 @@ class Page < ActiveRecord::Base
IMAGE_SIZES = ActiveSupport::OrderedHash.new
IMAGE_SIZES['large'] = '1000x'
IMAGE_SIZES['normal'] = '700x'
IMAGE_SIZES['small'] = '240x'
IMAGE_SIZES['small'] = '180x'
IMAGE_SIZES['thumbnail'] = '60x75!'

MAX_PAGE_RESULTS = 1000
Expand Down
2 changes: 1 addition & 1 deletion app/models/project.rb
Expand Up @@ -154,7 +154,7 @@ def to_json(opts={})
if opts[:include_collaborators]
attrs[:collaborators] = other_collaborators(acc).map {|c| c.canonical(:include_organization => true) }
end
attrs['title'] ||= "[Temporary Reviewer]"
attrs['title'] ||= "[Untitled Project]"
attrs.to_json
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/accounts/enable.html.erb
Expand Up @@ -13,7 +13,7 @@
</div>
<% end %>
<div class="line welcome">
Please set a password for your DocumentCloud account. Once you log in, you'll be able to add additional accounts for colleagues in your newsroom.
Please set a password for your DocumentCloud account. Once you log in, you'll be able to add additional accounts for colleagues in your newsroom. Note: you can also use this form to reset the password on an existing account.
</div>
<div class="line">
<div class="text_input">
Expand Down Expand Up @@ -43,4 +43,4 @@
if (e.which == 13) this.submit();
});
$('.minibutton.submit').click(function(){ $('#full_screen_form form').submit(); });
</script>
</script>
2 changes: 1 addition & 1 deletion app/views/admin/test_embedded_search.html.erb
Expand Up @@ -17,7 +17,7 @@
<body style="margin:0; padding:0;">
<div class="DC-embed-preview">

<div id="embed_1" style="width:280px"></div>
<div id="embed_1" style="width:370px"></div>

<script type="text/javascript">
dc.embed.load('<%= DC.server_root(:force_ssl => true) %>/search/embed/', {
Expand Down
6 changes: 4 additions & 2 deletions app/views/help/index.markdown
@@ -1,6 +1,8 @@
# Welcome to DocumentCloud

From the workspace, you can:
If you're just looking to get started, try our [guided tour][], or take a look at [what other reporters are doing with DocumentCloud][].

Find out how to:

* [Search][] the existing repository of public documents.
* [Upload document files][] of your own.
Expand All @@ -18,7 +20,7 @@ If you're looking at a list of documents (search results, your documents, a sing

<img src="/images/help/drag_select.png" class="full_line" />

If you're just looking to get started, try searching the documents already in the repository. Click on the "[Documents][]" tab and try a regular full-text search such as "[obama health care][]", or a more specific fielded search, such as "[person:geithner term:regulator][]".
Double-click a document's title to launch a viewer, where you can edit and annotate the document, if it belongs to you.

Right-click on a document to open a context menu, showing a list of actions that can be done to the document.

Expand Down
2 changes: 1 addition & 1 deletion app/views/help/links/searching_ajax_links.markdown
Expand Up @@ -22,4 +22,4 @@
[country: Iran]: #search/country%3A%20Iran

[the API]: #help/api
[API documentation]: #help/api
[API documentation]: #help/api
2 changes: 2 additions & 0 deletions app/views/home/contributors.yml
Expand Up @@ -175,6 +175,8 @@ contributors:
- http://www.darkacres.com
- - Dart Center for Journalism & Trauma
- http://dartcenter.org
- - Dateline Carolina
- http://www.datelinecarolina.org/
- - Democrat and Chronicle
- http://www.DemocratAndChronicle.com
- - The Denver Post
Expand Down
2 changes: 1 addition & 1 deletion app/views/jst/editor/control_panel.jst
Expand Up @@ -9,7 +9,7 @@
<div class="control_panel_title gradient_light">
<span class="">Document Tools</span>
</div>
<% if (isOwner) { %>
<% if (isOwner || isReviewer) { %>
<div class="public_annotation button">
<div class="icon mini_note"></div>
<div class="icon cancel_search"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/jst/workspace/account/dialog.jst
@@ -1,4 +1,4 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody id="account_list_content">
<tbody class="account_list_content">
</tbody>
</table>
2 changes: 1 addition & 1 deletion app/views/jst/workspace/document/upload_document_tile.jst
Expand Up @@ -50,7 +50,7 @@
<select name="access" class="document_access" id="document_upload_access_<%= model.id %>">
<option value="public">Public Access</option>
<option value="private" selected="true">Private Access</option>
<option value="organization">Private to <%= dc.app.organization && dc.app.organization.name %></option>
<option value="organization">Private to <%= dc.account.organization.name %></option>
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/jst/workspace/workspace/panel.jst
Expand Up @@ -4,7 +4,7 @@
<div class="tab_corner left"></div>
<div class="tab_corner right"></div>
</div>
<div id="help_tab" data-tab="help" class="tab trailing interface">
<div id="help_tab" data-tab="help" class="tab trailing">
Help
<div class="tab_corner left"></div>
<div class="tab_corner right"></div>
Expand Down
2 changes: 0 additions & 2 deletions app/views/note_embed/loader.js.erb
Expand Up @@ -6,8 +6,6 @@
window.dc = window.dc || {};
window.dc.recordHit = "<%= root.sub('s3', 'www') %>/pixel.gif";

<% root = DC.server_root(:ssl => false) %>

var loadCSS = function(url, media) {
var link = document.createElement('link');
link.rel = 'stylesheet';
Expand Down
3 changes: 1 addition & 2 deletions app/views/search_embed/loader.js.erb
Expand Up @@ -4,8 +4,7 @@

<% root = DC.server_root(:ssl => false) %>
window.dc = window.dc || {};

<% root = DC.server_root(:ssl => false) %>
window.dc.recordHit = "<%= root.sub('s3', 'www') %>/pixel.gif";

var loadCSS = function(url, media) {
var link = document.createElement('link');
Expand Down
1 change: 1 addition & 0 deletions config/database.yml
Expand Up @@ -4,6 +4,7 @@ defaults: &defaults
adapter: postgresql
encoding: unicode
schema_search_path: public
pool: 5
username: <%= secrets['username'] %>
password: <%= secrets['db_password'] %>
allow_concurrency: true
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -58,6 +58,7 @@

map.pdf "/documents/:id/:slug.pdf", :controller => :documents, :action => :send_pdf
map.full_text "/documents/:id/:slug.txt", :controller => :documents, :action => :send_full_text
map.page_text "/documents/:id/preview/", :controller => :documents, :action => :preview, :conditions => {:method => :get}
map.page_text "/documents/:id/pages/:page_name.txt", :controller => :documents, :action => :send_page_text, :conditions => {:method => :get}
map.set_text "/documents/:id/pages/:page_name.txt", :controller => :documents, :action => :set_page_text, :conditions => {:method => :post}
map.page_image "/documents/:id/pages/:page_name.gif", :controller => :documents, :action => :send_page_image
Expand Down
7 changes: 3 additions & 4 deletions lib/dc/search/query.rb
Expand Up @@ -228,10 +228,9 @@ def build_fields
# Lookup projects by title, and delegate to `build_project_ids`.
def build_projects
return unless @account
projects = Project.accessible(@account).all(:conditions => {:title => @projects})
doc_ids = projects.map{|proj| proj.document_ids }.flatten.uniq
doc_ids = [-1] if doc_ids.empty?
if doc_ids.present?
projects = Project.accessible(@account).all(:conditions => {:title => @projects}, :select => [:id])
project_ids = projects.map {|p| p.id }
if project_ids.present?
@populated_projects = true
else
project_ids = [-1]
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/app.rake
Expand Up @@ -22,7 +22,7 @@ namespace :app do

task :warm do
secrets = YAML.load_file("#{Rails.root}/secrets/secrets.yml")[RAILS_ENV]
sh "curl -s -u guest:#{secrets['guest_password']} http://localhost:80 > /dev/null"
sh "curl -s -u #{secrets['guest_username']}:#{secrets['guest_password']} http://localhost:80 > /dev/null"
end

task :console do
Expand Down
2 changes: 2 additions & 0 deletions public/javascripts/app/editor.js
Expand Up @@ -47,6 +47,8 @@ _.extend(dc.app.editor, {
$('.DV-docViewer').addClass(access);
$('.DV-well').append(this.controlPanel.render().el);
$('.DV-logo').hide();
$('.DV-thumbnailsView').show();
currentDocument.api.roundTabCorners();
var supp = $('.DV-supplemental');
if (supp.hasClass('DV-noNavigation')) {
supp.removeClass('DV-noNavigation').addClass('DV-noNavigationMargin');
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/app/hotkeys.js
Expand Up @@ -53,7 +53,7 @@ dc.app.hotkeys = {

// Check a key from a jQuery event and return the common english name.
key : function(e) {
return this.KEYS[e.keyCode || e.which];
return this.KEYS[e.which];
},

// Colon is special, since the value is different between browsers.
Expand Down
8 changes: 1 addition & 7 deletions public/javascripts/app/searcher.js
Expand Up @@ -49,7 +49,7 @@ dc.controllers.Searcher = Backbone.Router.extend({
options || (options = {});
if (options.clear) {
Documents.reset();
this.box.value('');
this.searchBox.value('');
}
if (this.currentSearch) return;
if (!Documents.isEmpty()) {
Expand Down Expand Up @@ -83,12 +83,6 @@ dc.controllers.Searcher = Backbone.Router.extend({
},

publicQuery : function() {
var projectName;
var query = this.box.value();

// Swap out documents for short ids.
query = query.replace(/(document: \d+)-\S+/g, '$1');

// Swap out projects.
var projects = [];
var projectNames = VS.app.searchQuery.values('project');
Expand Down
10 changes: 10 additions & 0 deletions public/javascripts/lib/jquery_extensions.js
@@ -1,5 +1,15 @@
(function($) {

// First things first, add our special CSRF token to every jQuery Ajax
// request.
$(document).ajaxSend(function(e, xhr, options) {
var token = $("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});

var fakeInput = document.createElement('input');
var supportsPlaceholder = 'placeholder' in fakeInput;

$.fn.extend({

// Align an element relative to a target element's coordinates. Forces the
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/model/accounts.js
Expand Up @@ -17,6 +17,7 @@ dc.model.Account = Backbone.Model.extend({
BLANK_ACCOUNT : {first_name : '', last_name : '', email : '', role : 2},

constructor : function(attributes, options) {
if (attributes) attributes = _.extend({}, this.BLANK_ACCOUNT, attributes);
Backbone.Model.call(this, attributes || this.BLANK_ACCOUNT, options);
},

Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/model/documents.js
Expand Up @@ -493,5 +493,5 @@ dc.model.DocumentSet = Backbone.Collection.extend({

_.extend(dc.model.DocumentSet.prototype, dc.model.Selectable);

// The main sets of Documents, used by the search tab, and the publish tab.
window.Documents = new dc.model.DocumentSet();
// The main set of Documents.
window.Documents = new dc.model.DocumentSet();
8 changes: 6 additions & 2 deletions public/javascripts/ui/accounts/account_dialog.js
Expand Up @@ -28,7 +28,7 @@ dc.ui.AccountDialog = dc.ui.Dialog.extend({
this._container.setMode('not', 'draggable');
this._container.html(JST['account/dialog']({}));
if (Accounts.current().isAdmin()) this.addControl(this.make('div', {'class': 'minibutton dark new_account', style : 'width: 90px;'}, 'New Account'));
this.list = this.$('#account_list_content');
this.list = this.$('.account_list_content');
this._renderAccounts();
return this;
},
Expand Down Expand Up @@ -56,7 +56,11 @@ dc.ui.AccountDialog = dc.ui.Dialog.extend({
},

newAccount : function() {
var view = new dc.ui.AccountView({model : new dc.model.Account(), kind : 'row'});
var view = new dc.ui.AccountView({
model : new dc.model.Account(),
kind : 'row',
dialog : this
});
this.list.append(view.render('edit').el);
this._container[0].scrollTop = this._container[0].scrollHeight;
},
Expand Down
6 changes: 2 additions & 4 deletions public/javascripts/ui/accounts/account_view.js
Expand Up @@ -60,7 +60,6 @@ dc.ui.AccountView = Backbone.View.extend({
}, options);
if (this.isRow()) this.setMode(viewMode, 'view');
$(this.el).html(this.template(attrs));
console.log(['role render', this.model.get('role'), this.model, viewMode]);
if (viewMode == 'edit') this.$('option.role_' + this.model.get('role')).attr({selected : 'selected'});
if (this.model.isPending()) $(this.el).addClass('pending');
this._loadAvatar();
Expand Down Expand Up @@ -89,7 +88,7 @@ dc.ui.AccountView = Backbone.View.extend({
},

promptPasswordChange : function() {
dc.app.accounts.close();
this.dialog.close();
var dialog = dc.ui.Dialog.prompt('Enter your new password:', '', _.bind(function(password) {
this.model.save({password : password}, {success : _.bind(function() {
dc.ui.notifier.show({
Expand Down Expand Up @@ -124,7 +123,7 @@ dc.ui.AccountView = Backbone.View.extend({

_openAccounts : function(e) {
e.preventDefault();
dc.app.accounts.open();
this.dialog.open();
},

// When we're done editing an account, it's either a create or update.
Expand Down Expand Up @@ -169,7 +168,6 @@ dc.ui.AccountView = Backbone.View.extend({
description : this.model.fullName() + ' will not be able to log in to DocumentCloud. Public documents and annotations provided by ' + this.model.fullName()+ ' will remain available. <span class="contact_support text_link">Contact support</span> to completely purge '+this.model.fullName()+'\'s account.',
saveText : 'Disable'
});
console.log(['dialog', dialog]);
$('.contact_support', dialog.el).bind('click', function() {
dialog.close();
dc.ui.Dialog.contact();
Expand Down
17 changes: 2 additions & 15 deletions public/javascripts/ui/documents/document_embed_dialog.js
Expand Up @@ -60,6 +60,7 @@ dc.ui.DocumentEmbedDialog = dc.ui.Dialog.extend({
this._viewerSizeEl = this.$('select[name=viewer_size]');
this._sidebarEl = this.$('input[name=sidebar]');
this._showTextEl = this.$('input[name=show_text]');
this._showPDFEl = this.$('input[name=show_pdf]');
this._openToEl = this.$('.open_to');
if (dc.app.preferences.get('embed_options')) this._loadPreferences();
this.setMode('document_embed', 'dialog');
Expand Down Expand Up @@ -104,6 +105,7 @@ dc.ui.DocumentEmbedDialog = dc.ui.Dialog.extend({
}
if (!this._sidebarEl.is(':checked')) options.sidebar = false;
if (!this._showTextEl.is(':checked')) options.text = false;
if (!this._showPDFEl.is(':checked')) options.pdf = false;
if (openToPage) options.page = parseInt(openToPage, 10);
if (openToNote) {
var note = this.model.notes.get(parseInt(openToNote, 10));
Expand Down Expand Up @@ -146,21 +148,6 @@ dc.ui.DocumentEmbedDialog = dc.ui.Dialog.extend({
this._showTextEl.attr('checked', options.text);
},

_renderOpenTo : function(e) {
switch ($(e.currentTarget).val()) {
case 'first_page':
return this._openToEl.empty();
case 'page':
return this._openToEl.html(JST['document/page_select']({doc : this.model}));
case 'note':
this.model.ignoreNotes = true;
this.model.notes.fetch({success : _.bind(function() {
this._openToEl.html(JST['document/note_select']({doc : this.model}));
delete this.model.ignoreNotes;
}, this)});
}
},

// Handles user selection of dropdown that controls which page/annotation
// the viewer opens on. Changes form, which is later serialized.
_renderOpenTo : function(e) {
Expand Down
1 change: 0 additions & 1 deletion public/javascripts/ui/documents/document_list.js
Expand Up @@ -27,7 +27,6 @@ dc.ui.DocumentList = Backbone.View.extend({

// Simply renders the list container, still waiting for documents.
render : function() {
this.setCallbacks();
$('.search_tab_content').selectable({
ignore : '.noselect, .minibutton',
select : '.icon.doc',
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/ui/search/search_embed_dialog.js
Expand Up @@ -107,6 +107,7 @@ dc.ui.SearchEmbedDialog = dc.ui.Dialog.extend({
update : function() {
this._renderPerPageLabel();
this._renderEmbedCode();
this._savePreferences();
},

embedOptions : function() {
Expand Down

0 comments on commit 0991724

Please sign in to comment.