Giter VIP home page Giter VIP logo

regulations-site's Introduction

⚠️ THIS REPO IS DEPRECATED (12/3/2018) ⚠️

Please migrate to using cfgov-refresh.

regulations-site

Build Status

An interface for viewing regulations data. This project combines all of the data from a parsed regulation and generates navigable, accessible HTML, complete with associated information.

This repository is part of a larger project. To read about it, please see http://cfpb.github.io/eregulations/.

Features

  • Navigability: Instead of the monolithic text usually used to represent regulations, proper indentation, spacing, etc., this presents the text in a clean, readable form.
  • Inline Interpretations: Associated interpretations are displayed right along side the paragraph/section/appendix they are interpreting.
  • Definitions: Defined terms are highlighted in the regulation text; clicking them opens the term's definition in the sidebar.
  • Internal Citations: Citations to other parts of the same regulation are clickable links, allowing easy navigation within a regulation
  • Alternate Versions of the Regulation: Quick access to versions of the regulation by browsing effective dates, or typing in an arbitrary date is provided.
  • Comparing Versions: A "Diff-view" is provided to highlight additions and deletions between versions of the regulation.
  • Section-by-Section Analysis: Analysis for regulation paragraphs/sections/appendices are provided in the sidebar. This analysis comes from Federal Register notice preambles.
  • Additional Formatting Concerns: Tables, subscripts, notes, and even source code found within a regulation are rendered as appropriate markup.
  • Responsive Design: The application design is responsive, adjusting to the device and screen size of the user.

Screenshot

eRegs

Requirements

This application lives in two worlds, roughly translating to a Python, Django app, and a Backbone, Javascript app, which communicate through the Django templates.

Quick start

If you're familiar with Python and Node environments, after cloning this repo:

$ mkvirtualenv regsite
$ workon regsite
$ pip install -r requirements.txt
$ ./frontendbuild.sh
$ python manage.py runserver

Python

Requirements are retrieved and/or build automatically via pip (see below).

  • lxml - Used to convert strings into XML for processing
  • requests - Client library for reading data from an API

If running tests:

  • mock - makes constructing mock objects/functions easy
  • django-nose - provides nosetest as a test runner
  • nose-exclude - allows certain directories to be excluded from nose
  • nose-testconfig - pass configuration data to tests; used to configure selenium tests
  • coverage - provides test-coverage metrics

Setup & Running

This project uses requirements*.txt files for defining dependencies, so you can get up and running with pip:

$ pip install -r requirements.txt       # modules required for execution
$ pip install -r requirements_test.txt  # modules required for running tests
$ pip install -r requirements_dev.txt   # helpful modules for developers

With that, you can start the development server:

$ python manage.py runserver

Building the documentation

For most tweaks, you will simply need to run the Sphinx documentation builder again.

$ ./bin/sphinx-build -b dirhtml -d docs/_build/doctrees/ docs/ docs/_build/dirhtml/

The output will be in docs/_build/dirhtml.

If you are adding new modules, you may need to re-run the skeleton build script first:

$ rm docs/regulations*.rst
$ ./bin/sphinx-apidoc -F -o docs regulations

JavaScript Application

Code

The application code in JavaScript uses Backbone.js as a foundation, though in some non-standard ways. If you plan to do work on this layer, it is recommended that you acquaint yourself with this starter documentation.

Environment

The front end of the site uses a number of JavaScript libraries and frameworks to create the unique experience of navigating and reading a regulation, as you can see at http://consumerfinance.gov/eregulations. If you'd like to modify the JavaScript layer, you should set up the build and testing environment.

If you run the application with env = "built" in your local_settings.py and would like to use the UI as it ships with this project, you can skip this.

The application's UI itself uses a number of dependencies that you can see in package.json. To start, we are going to be concerned with the foundations of the environment:

Front end environment setup

Node/npm

The front-end development environment relies on on Node (version 4+) and npm for package management. To install Node, we recommend nvm:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash # install nvm and run it's setup scripts
nvm install 4 # install node 4
nvm alias default 4 # set node 4 as the default

Alternately you can install Node by:

Global npm packages

You will need to install the Grunt command line interface using npm.

cd regulations-site
npm install -g grunt-cli

Installing dependencies

The rest of the dependencies you will need are managed by npm. Do:

npm install

Configuration JSON

In the root of the repository, copy example-config.json to config.json and edit as necessary. Grunt depends on these settings to carry out tasks.

  • testURL is the environment that you would like tests to run on.
  • frontEndPath is the path to the root of your codebase where the css/ and js/ directories are.
  • testPath is the path to the functional test specs.

Running the application

Once all of the Python and front end dependencies have been met, compile the CSS and JavaScript and start the server:

$ grunt
$ ./bin/django runserver

Building the documentation

For most tweaks, you will simply need to run the Sphinx documentation builder again.

$ ./bin/sphinx-build -b dirhtml -d docs/_build/doctrees/ docs/ docs/_build/dirhtml/

The output will be in docs/_build/dirhtml.

If you are adding new modules, you may need to re-run the skeleton build script first:

$ rm docs/regulations*.rst
$ ./bin/sphinx-apidoc -F -o docs regulations

Additional front end information

Running Grunt tasks

There are a number of tasks configured in Gruntfile.js. On the last lines, you will find tasks that group subtasks into common goals. Running grunt build will run unit, functional and lint tests, and compress static assets. Its recommended that you run this task before deploying changes.

Unit and Functional Tests

The Grunt build will run a suite of Selenium tests written in Python and a small suite of Mocha.js unit tests. All tests run in Sauce Labs. These tests run as part of the grunt build tasks. To use these, a little extra environment setup is required.

Sauce Labs Configuration

After you create a Sauce Labs account:

  • In your bash config (probably ~/.bash_profile), define two variables: $SAUCE_USERNAME and $SAUCE_ACCESS_KEY which house your username and access key from Sauce Labs.
  • If you want to test a local or otherwise not publically available environment, download and run Sauce Connect. If you do need Sauce Connect, you will need to start it before running tests/Grunt builds.
  • Be sure that the Django server is running in the environment you want to test.
For functional tests
  • They also require having the environment serving data from dummy_api/. To start the dummy API, from the root of your repo, run ./dummy_api/start.sh 0.0.0.0:8282.
  • The tests run using nose. If you wish to run the tests outside of the Grunt environment, you may by running nosetests regulations/uitests/*.py from the root of the repo.
For unit tests
  • Unit tests do not require running the dummy API.
  • To run the unit tests along with the functional tests: grunt test from the root of the repo.
  • To run unit tests individually: grunt mocha_istanbul from the root of the repo.

Font files

The CSS styles for this project refer to some font files which cannot be distributed publicly (see definitions in regulations/static/regulations/css/less/fonts.less). These fonts need to live under a fonts subdirectory of wherever static assets are served from, e.g. /static/fonts. There are fallback fonts defined which will be used if the desired fonts are not available.

If you want to install self-hosted fonts locally for use in development, you can place the font files in repo subdirectory static.in/cfgov-fonts/fonts/ and restart the local web server. If you are a CFPB employee, you can perform this step with:

cd static.in/ && git clone https://[GHE]/CFGOV/cfgov-fonts/

where [GHE] is our GitHub Enterprise URL.

See the cfgov-refresh Webfonts documentation for a similar setup.

Configuration

Update notices

Define an EREGS_REGULATION_UPDATES Django setting in order to temporarily place a notice on the landing page of regulations that are in the process of being updated. For example, to turn on this notice for regulations for part 1003 and part 1005, define:

# in your Django settings file
EREGS_REGULATION_UPDATES = ['1003', '1005']

Content for this notice can be found in regulations/templates/regulations/generic_landing.html.

regulations-site's People

Contributors

anselmbradford avatar ascott1 avatar chosak avatar cmc333333 avatar contolini avatar cwdavies avatar darthdippy avatar donjo avatar grapesmoker avatar hillaryj avatar jbarnicle avatar jehlers avatar khandelwal avatar kimberlymunoz avatar konklone avatar marcesher avatar mortonfox avatar niqjohnson avatar orlandosoto avatar rosskarchner avatar scotchester avatar theresaanna avatar willbarton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

regulations-site's Issues

TOC / main content scrolling inconsistent

When I leave the TOC open, and move to somewhere other than the top of the main content, the TOC panel won't scroll for me anymore -- the main body of the page scrolls instead.

Double markers

The inline interpretations display double (and sometimes triple) list markers.

Convert to Django App

First step is to serve this up as one big regulation page, but using django instead of static html files.

Analytics Tracking Issue

Hi -

We realized today that the tracking code that is being sent to the CFPB wide analytics account is not working from the /eregulations pages. The reason for this is that the tracking code is sending a universal tag to our account, however, our account has not been migrated to universal. All tags sending data to the CFPB wide account should be using the classic code.

Our basic pageview tracking:

script type="text/javascript"

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20466645-3']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/script

Please insert classic tracking code into all pages of eregulations. Thank you!

A way of separating out section numbers and titles

Many of the designs give a different visual treatment to the section number and the title of the section. Right now, typical markup looks like:

<h2 class="section-title"> § 1005.1 Authority and purpose. </h2>

Ideally the markup would be something like:
`

§ 1005.1

Authority and purpose.

``

Admittedly that's pretty ugly, so I am open to better markup solutions.

Plato error on grunt build

CM and Shashank get the following on grunt build

Running "plato:all" (plato) task
Could not parse JSON from file regulations/static/regulations/docs/complexity/files/app_init_js/report.history.json

Hotkey for TOC

A hotkey to activate the TOC and move focus to it would be useful for keyboard users.

Ideally, it should remember where the user was in the document and move focus back if they hit the key again without first navigating elsewhere.

Focus when using TOC

When a user opens the TOC, tabs in, and follows a link, focus should go to the section they've tried to navigate to. Right now, it stays in the TOC list (so if I tab to the link for 1005.4, hit enter, my text scrolls but when I tab it goes to the link to 1005.5 instead of to the first link in that section)

Inline Interpretations missing <li>'s

Once layers are applied to the inline interpretations, the paragraphs are no longer contained within

  • tags, though the each section is still within an
      .

  • Convert Reg Title to Lowercase

    If the reg title is in lowercase, we can convert it to title case or uppercase with CSS... sadly, CSS doesn't let us change the case when the text is already in uppercase.

    Interpretations List Markers

    The interpretations follow a different marker pattern from the rest of the reg and require different markup to ensure the proper list markers are applied.

    The pattern of interpretations markers are as follows:

    1.
      i.
        A.
    

    They also seem to only be nested two deep (in both Reg E & Z - this would need to be verified).

    Proper markup:

    First level interpretations should be given a list type of "1":

    <ol type="1">

    Second level lists should be given a list type of "i":

    <ol type="i">

    Third level lists should be given a list type of "A":

    <ol type="A">

    Key terms and defined word don't play nicely

    If something is a defined word and a keyterm, the keyterm bit doesn't apply correctly right now. We applied a hotfix that fixes this, remove the hotfix - and provide a more long term fix.

    Missing links in the interpretation section

    Right now there are no internal/external links in the interpretation section at the bottom of the regulation. I think this is due to the 999-Interpretations-2-a vs. I-999-2-a change.

    Key terms that are also definitions do not have the proper markup

    Key terms that are also definitions do not currently receive the key term markup. For examples, see all of 1005.2 or 1005.3 b.

    In the case of 1005.3 b, it should be marked up as follows:

    <dfn class="key-term" dfn-key-term="electronic-fund-transfer"><a href="#1005-2-g" class="citation definition" data-definition="1005-2-g">Electronic fund transfer</a></dfn>

    In the long-term, I think it would make the most sense not to exclude the definition link as well (but that may need to be part of a larger discussion):

    <dfn class="key-term" dfn-key-term="electronic-fund-transfer">Electronic fund transfer.</dfn>

    Add skip link

    There should be a link near the top of the document to skip past the TOC and go straight to 1005.1 -- this is a feature for screen reader users on old browsers. It's safe to hide the link offscreen the same way the TOC is.

    Surfacing titile in inline interpretations

    Currently inline interpretations read:

    Supplement I - Official Interpretations

    Ideally they should specify what the interpretation is, such as:

    Supplement to 3(b)(1)

    Is this something that should be done on the back-end through templates?

    Dealing with JS dependencies

    A couple of weeks ago, I submitted a pull request where npm now pulls a dependency from a fork of a Grunt module on my personal account because I've pull requested a feature that is essential for us back to the project, but its a slow moving project.

    As I'm porting us over to Bower to manage JS dependencies, I'm finding that a couple of libraries that we depend on do not have Bower support. I am submitting pull requests to add the requisite config files to the projects, but in lieu of those merges and other necessary versioning changes by the maintainers, we have to find another way.

    Options:

    1. Continue to keep these libraries checked into our repository. Much of the impetus for this move to Bower is that it doesn't feel right to include these dependencies as part of the codebase. TBH, I don't know what licenses these libs ship with and I'm not sure that we could bring this repo under CFPB w/o managing them properly.

    2. Bower can install from an arbitrary GitHub URL instead of the URL is has associated in its registry with a package name. So, we can install from the project's GitHub URL, but we run the risk of things going south if the maintainer makes changes to the file structure.

    3. We can have Bower install the dependency from my fork of the librar(y/ies). The up side to this is that it is predictable - it will stay a snapshot of the library as it exists now.

    Votes?

    Interpretation missing headers

    Right now, the markup that we spit out for interpretations (Supplement I) doesn't have any headers. That makes navigation almost impossible.

    Add tabindex=0 to headers

    This will make sure users tabbing through the document will stop at each header, and also make it easier to assign focus to a section

    TOC characters displayed weird

    The smaller TOCs seem to have weird characters (no better way to describe this). When I hover, they go away, but they come back when I de-hover.

    Inline interpretations below section

    Right now, I can't tell if the inline interpretations refer to the section above or below the gray box. They should be underneath the section they are referring to.

    Set up Travis

    This is a little more complicated as we want both JS and Python tests to be ran.

    External links not working

    External links return an error page:

    Problem detected

    There was a System error while searching. Please contact FDSys API Administrator for assistance.
    Please report this error to [email protected]'

    Please provide the following information to help us resolve this problem: the URL of the page you were trying to access, the steps you followed to produce the error, specific search or browse terms, and/or a screenshot of the page where the error occurred.

    Please refer FDSys API documentation for more information

    Request Details

    • Service Requested: link
    • Request Parameters:
    • link-type - html
    • section - 1693
    • year - mostrecent
    • title - 15
    • collection - uscode

    http://api.fdsys.gov/link?section=1693&year=mostrecent&link-type=html&collection=uscode&title=15

    Layers are only applied once.

    If a particular layers says that there are more than one definition, citation etc in a body of text, only the first one is dealt with. Subsequent instances are ignored.

    Section tag id has incorrect content in appendices

    Markup outputs title in id attr:

    <section id="Section 1005.20Requirements for Gift Cards and Gift Certificates">

    instead of some version of this:

    <section id="1005-20-I">

    or whatever pattern we choose for these sections

    Prob coming from appendix.html, c.markup_id

    Overarching experience discussion

    For full-js capability users, I'm leaning toward having an infinite-scroll experience of the entire reg. This will allow ctrl-F and smoother jumping between sections of the reg when necessary for use. My thought is that we will wind up dynamically loading a lot of the content, rather than loading it in one chunk.

    Would we rather support non-js users by serving the entire reg in one chunk or by creating a paged experience with each section (e.g. 1005.1) being its own page? I don't think there's anything in either approach that precludes an infinite-scroll type experience from full-js users, but it does affect the way and order we load those things. I think.

    Search/Replace with offsets is breaking internal citations.

    Consider "Section 99.15(d)(2)(i) blah blah. § 99.15(d)(2) says something"

    This line has two citations: 99.15(d)(2)(i) and 99.15(d)(2).

    Unfortunately, the current strategy for search and replace causes this to produce something like:
    <a href="99-15-d-2-i"><a href="99-15-d-2">99.15(d)(2)</a>(i)</a> due to the first citation containing the second.

    Appendix links not working

    Links in the Appendix TOC are not working. Not sure the cause as they appear to be pointing to the correct content.

    Navigation ID's

    Right now appendix nav's are given the same ID as the full reg nav. This is invalid HTML as only one element per page can have an ID.

    <nav id="menu"> appears multiple times throughout the document.

    Thoughts on lazyload order

    Load sections of the reg as a stack, with this as the default order. The user requesting a specific piece of information will move it to the top of the stack (I realize that a user who clicks around a lot initially will pull several things to the top of the stack, but I think we should always fulfill the most-recent user request first)

    1. Page structure and chrome
    2. TOC
    3. "loading" animation/gif/etc for use when user requests something that hasn't loaded yet [this will need to be designed]
    4. Main sections in numerical order (1005.1, 1005.2, etc)
    5. Appendix A
    6. Non-text assets for Appendix A
    7. Interpretations in pieces (for inline use)
    8. History and other metadata layers (as we fill these in we'll need to determine a load order, or if they need to be broken up)
    9. Individual definitions (in order they appear in 1005.2)
    10. Preamble
    11. Full text of other appendices in order

    This is a hypothesis. Please discuss and challenge it.

    Focus when opening a definition

    When a user activates a definition link, the browser's focus should move to the beginning of the definition.

    At the end of that definition, there should be a link to send them back to where they were in the text.

    Chrome z-index

    In Chrome the content (sometimes) flashes above the persistent header when clicking an internal link.

    IE Compatibility Mode issues

    We've received feedback from some users that the tool has triggered IE's "compatibility mode" despite our best efforts to prevent this through meta tags.

    Here are thoughts on how we can fix or improve this experience:

    1. Figure out what's causing this and fix it. Sounds obvious, but the reason for compatability mode being triggered is opaque. @theresaanna pointed out that it may be caused by slow connection speeds, which could be a common (and unfixable) scenario for IE8 users.
    2. Add limited IE7 support. We made a conscious decision to not support IE7 and lower, but browser testing indicates that the only major IE7 issue is the rendering of the drawer. We can spend some time fixing this, which will greatly improve the experience for IE users in compatibility mode.
    3. Improve the browser warning message. Currently the browser warning message is the default HTML5 Boilerplate warning. Improving the copy could be a simple first step. Check out the screenshot of Github's browser warning below:

    screen shot 2013-10-25 at 1 38 29 pm

    I'm leaning towards first implementing option 3 and then devoting time to option 2. Thoughts @theresaanna @cmc333333 @khandelwal @jpyuda @jehlers ?

    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.