Giter Site home page Giter Site logo

muckrock / documentcloud-frontend Goto Github PK

View Code? Open in Web Editor NEW
15.0 10.0 5.0 12.49 MB

DocumentCloud's front end source code - Please report bugs, issues and feature requests to [email protected]

Home Page: https://www.documentcloud.org

License: GNU Affero General Public License v3.0

Makefile 0.12% JavaScript 29.62% HTML 0.03% CSS 0.80% Shell 0.07% Svelte 64.85% SCSS 0.54% Python 1.06% TypeScript 2.91%
documentcloud document viewer manager

documentcloud-frontend's Introduction

DocumentCloud frontend

DocumentCloud Frontend · Squarelet · MuckRock · DocumentCloud

The main frontend for DocumentCloud, written in Svelte.

Usage

This project depends on both Squarelet and the DocumentCloud (Django). Follow the steps in their READMEs before setting up this project.

This project is a Svelte + Webpack project wrapped in Docker compose.

In order to install dependencies inside the Docker container, run:

make install

Once the node modules have been installed, start the app with:

make dev

Warning: Don't just run docker compose up like you would with some of the other repos. The containers listed in local.yml aren't intended to be run simultaneously.

Set up your hosts:

echo "127.0.0.1 www.dev.documentcloud.org" | sudo tee -a /etc/hosts

Once everything is up and running, you should be able to see the website live at www.dev.documentcloud.org. Note the frontend is not yet functional.

Building for production

Run make build to build the production version of the app. The project will be output in the public directory.

Architecture

See the Wiki for information on the DocumentCloud architecture.

Browser support

DocumentCloud is tested and runs on recent versions of modern browsers -- Chrome, FireFox, Safari and Microsoft Edge. Older versions of those browsers will likely work, too, but we can't guarantee a bug-free experience on versions from more than a year ago, or on browsers that no longer receive updates, such as Internet Explorer.

Developing

Installing new packages

Run the relevant npm install ... command and then get the change mirrored on the Docker image by running make install.

Unit tests

Run unit tests with npm test.

Browser tests

All of the browser test commands depend on the front end running, so start the app with make dev and start the backend and Squarelet as well.

Running tests locally

Run npm run test:browser in another terminal. This will run Playwright using Chromium and Firefox.

Development

The functional tests are organized like this:

tests
├── README.md
├── anonymous
│   ├── manager
│   │   └── app.spec.js
│   ├── pages
│   │   └── home.spec.js
│   └── viewer
│       └── document.spec.js
└── fixtures
    ├── Small pdf.pdf
    ├── development.json
    ├── production.json
    ├── staging.json
    └── the-nature-of-the-firm-CPEC11.pdf

Tests are organized around major parts of the codebase -- manager, pages and viewer. Tests under anonymous don't use an authenticated user.

Tests rely on specific docouments available in each environment, which will have different URLs, so lists of known documents are provided in development.json, staging.json and production.json. Those correspond to the NODE_ENV environment variable.

Storybooks

Storybooks are used to create isolated environments for developing, testing and demonstrating the Svelte components that compose the user interface.

Storybooks run locally to your machine, not in the Docker container.

To run the Storybook dev server:

npm run storybook

To set and manage your Node version, you can use NVM:

node -v
nvm install 16
# or
nvm install --lts

Thanks

Chromatic

Thanks to Chromatic for providing the visual testing platform that helps us review UI changes and catch visual regressions.

documentcloud-frontend's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

documentcloud-frontend's Issues

Support for page notes

These are notoriously difficult to implement without breaking a lot of layout (since everything else has deterministic dimensions). Will need to think of a way around this

Update document URLs to point to id-slug

When you click into a document, it should take you to:

/documents/20000478-slug

This should be noted as the canonical URL within the HTML metadata to avoid duplicate content penalties. Note that any URL starting with /documents/20000478 will render the correct document, as the system ignores everything after the ID at the beginning. We're including the slug to improve URL readability, reduce changes with the old search system, and help improve SEO

Informative/Help text

This issue tracks general text additions that would be helpful and informative

  • Logged out view: about panel in place of projects panel
  • One-line quick text to help with search (that pops out a panel with more usage info)

Multilingual support

  1. Support OCR for different languages, as we do now
  2. Allow searching by language
    • Can also customize search per language, but that is more complicated
  3. Better handling of setting your default language and overriding for a new document
  4. Handling of setting default document and UI language on an organization
  5. Translating the UI into different languages

Beta Feedback Link

Need an easy way for Beta users to contact us with any problems they find... maybe just a prominent mailto: link for now?

Set access level during upload

Some users were confused about setting access level during upload, and assumed was public. I think it makes sense to add a dialogue to make this a choice during upload — sometimes people just want to rush to make things public, and we want to be building inducements to make more public vs. private over time, while avoiding stuff accidentally going public when it shouldn't.

First-time users have to log in twice

Investigate why this is happening. After a new user logs in from the home page, it redirects to the manager page logged out view. From there, you have to log in again in the manager.

The best user experience would be to be logged in directly and see the "Upload your first docs" message

Complete Authentication Story

Right now detection of logged in users is not functioning appropriately. This should be implemented along with a link to sign out

Feature Request: Book-style viewer

Via a user, and think is worth exploring down the line:

I was wondering if there is any possibility that Document Cloud will develop a means to display PDFs in booklet form that is also website embeddable? I.e. a flipbook. There are several services out there that offer this feature, but they are all paid. Issuu used to offer a free ad-supported version but it is no longer embeddable on one's own website. Would greatly appreciate this feature, which we could use with DocumentCloud's own logo/branding.

Add force OCR option

Already supported by the backend. This should be exposed in the doc viewer and potentially available upon upload

switch bulk process api to new format

/api/documents/process/ should switch from {"ids": [1,2,3]} to [{"id": 1}, {"id": 2, "force_ocr": true}, {"id": 3}

Front end may expose UI for forcing OCR - processing endpoint for a single document accepts the option as well

Document viewer sometimes doesn't show pages

If you take a long document and rapidly scroll somewhere in the middle, occasionally nothing renders. When you scroll slightly or resize the window it fixes it. Should have code to ensure that never happens

Text mode jittery

Switching from image to text mode when the pages are smaller in text mode sometimes causes jittering that dislodges the appropriate current page. Should look into what's causing this to eliminate it

Support for static pages

Some way for staff to have access to some sort of CMS to make static pages, such as an about page or help page

Instantly start uploaded/processing on embed

Would it be possible to merge the naming verification/upload progress screens, and then if the name is changed just have that patch as a name change operation, and cancelling an upload delete those files?

I am so often using DocumentCloud in a hurry, when I want to get the document out as fast as possible.

As I just started an upload of 7 documents (drag-and-drop), and note that DC wanted me to fix up their names before starting the upload.

I would much rather have the upload begin ASAP and be presented with the same dialog box that would let me fix up the names after.

Make document viewer more fluid

I have a couple ideas to make the document viewer more fluid and ease future expansions like page notes. Time-permitting, I will investigate using transform matrices to be able to zoom natively like a PDF document and handling touch/gestures with appropriate events. I also want to handle image scaling with DPI

Logged out app view shows "+Upload" and "+New Project" buttons

Since these tools don't work, there should be a check on whether someone has the access rights to them (long term shouldn't be just signed in/not signed in because we're adding ability for non-verified journalists to be logged in).

Should probably also get rid of the project text that says:

Projects + New Project
Create your first project by clicking “New Project” above.

And maybe replace with something that's like an "About Document" that explains a little bit about what the site is and how to apply. Will try to add some usable language.

Support for URL extensions

DocumentCloud currently supports a number of special extensions that can just be added to the DocumentCloud URL (some are documented here):

.txt: Shows just the OCRd text as a txt file.
.pdf: Links to the raw PDF
/p2: links to specific page
/p57/a42283: links to a specific note

And I think there's also something that shows you just the text from a specific page but can't find it?

View all documents searches hang

If you're logged out and view the beta page, search appears to just hang indefinitely.

Additionally, if you're logged in and click "All Documents" or try and run an empty search, the query also doesn't work, though it doesn't visibly hang, it just doesn't appear execute the query. Putting in any data in the field (such as access:public) does appear to work fine.

Account Settings Links

Users should have a way to get get to accounts.muckrock.com from DocumentCloud so they can manage settings, invite users, etc.

I could see this going either right above "Sign Out" in the dropdown, or on the left hand side of the page. I think people will have a fair number of questions about adding additional users, etc. so making it pretty prominent would be helpful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.