Commit Graph

40 Commits

Author SHA1 Message Date
Chris Hill-Scott
2f0cc99610 Make URLs for assets cache-proof
https://www.pivotaltracker.com/story/show/113448149

This commit adds a query string to assets URLs which is generated from a hash
of the file contents. When asset files are changed they will now be served from
a different URL, which means they wont be loaded from browser cache.

This is similar to how GOV.UK template adds its version number as a querystring
parameter for its assets.

This is mostly copied from Digital Marketplace utils:
https://github.com/alphagov/digitalmarketplace-utils/pull/102

They have it in a shared codebase, we only have one frontend app so don’t need
to do that.

Usage in a template:
``` jinja
{{ asset_fingerprinter.get_url('stylesheets/application.css') }}
```

Output:
```
static/stylesheets/application.css?418e6f4a6cdf1142e45c072ed3e1c90a
```
2016-02-10 16:00:29 +00:00
Chris Hill-Scott
3135f6c510 Use different colours for each environment
https://www.pivotaltracker.com/story/show/112786779

> There's an emerging convention on admin apps, to have a red strip atop the
> page, also to have a different colour for preview environment... so let's
> adopt that and see how it feels. Red for prod and gold for preview.

This commit adds config so that:
- yellow locally
- orange on preview and staging
- red on live

It will not actually work until each AWS environment uses the right config, but
can be tested locally by setting the environment variable manually, eg:
`export HEADER_COLOUR='#F47738'`
2016-02-01 15:35:19 +00:00
Chris Hill-Scott
2ef1057180 Make spacing and position of banners consistent
Banners should always be the first thing on the page.

Because headers already have padding we don’t want to put padding on the
container.

So banners should also have top padding to distance then from the red bar.

They should also sit in the 3/4 column if the page has side navigation. This
commit adds a new template (`withoutnav_template.html`) which extends
`admin_template.html`. All views then extend one or the other, never the
`admin_template.html` directly. This means that `admin_template.html` doesn’t
have to make decisions about where the flash messages are displayed.
2016-02-01 13:52:46 +00:00
Chris Hill-Scott
f6aed4fa06 Remove ‘BETA’ label
There’s an argument to be made that the beta label should only apply to
the public-facing parts of services/platforms.

Removing it from here means that we don’t need to deal with the hassle of how it
fits into the navigation. If we have to bring it back then we could follow the
banner example here instead:

http://govuk-elements.herokuapp.com/alpha-beta-banners/#beta-banner
2016-02-01 13:52:46 +00:00
Chris Hill-Scott
3617f2e936 Move service and user nav to proposition header
This commit moves user-related navigation into the proposition header (the black
bar) at the top of the site. It adds some custom SASS to override GOV.UK
template and align these navigation items to the right (because it looks
better).

It then removes the service chooser dropdown (and its associated SASS and JS) in
favour of a link alongside the user-related navigation items. ‘Switch service’
is the best language for this that we’ve come up with so far.

This means that the only way of adding a new service is from the `/services`
page. So this commit removes the redirect if you land on this page with only one
service (else it would prevent you from ever being able to add more).
2016-02-01 13:52:45 +00:00
Rebecca Law
867ef7ad99 Default service name if service name is not set on the session.
Pop service name off the session on sign out.
2016-01-29 10:40:55 +00:00
Rebecca Law
0dd20abbb3 Replace Current service with chosen service name. 2016-01-28 17:20:34 +00:00
Rebecca Law
20e3d1952f Add import for banner 2016-01-27 15:22:47 +00:00
Chris Hill-Scott
e03813ceef Make 'API key was revoked' banner green 2016-01-26 16:26:08 +00:00
Chris Hill-Scott
4e158e203c Update styleguide 2016-01-26 16:20:57 +00:00
Martyn Inglis
e279d8f98c Removed dodgy symbols from link text 2016-01-22 23:21:15 +00:00
Martyn Inglis
fb3b6510c4 Added template ID to template page, to allow users to identity required data for API calls. 2016-01-22 12:44:19 +00:00
Martyn Inglis
79c21388bb Content changes for switching services 2016-01-22 10:38:29 +00:00
Chris Hill-Scott
482abb97d5 Put message previews on ‘Send SMS’ page
A previous commit removed these to differentiate between this page and the
manage templates page. It turns out that we do want previews on this page
because:
- the users for the two pages might be different—they might only be allowed to
  do one or the other depending what permissions they have
- it’s useful to see what the placeholders in the message are before uploading
  a CSV, to make sure the CSV has the correct column headings

This commit re-adds the message preview with a simpler UI. Discussed with
@antimega and we both agreed that the speech bubble tails on the messages should
go.
2016-01-20 13:12:20 +00:00
NIcholas Staples
6c46d92dd4 Merge pull request #86 from alphagov/use-html5-details-for-switcher
Use HTML5 details element for the service switcher
2016-01-19 12:09:42 +00:00
Chris Hill-Scott
a08089a47d Use HTML5 details element for the service switcher
The previous service switcher was built purely in Javascript, which meant that,
for the purposes of progressive enhancement, it had to load in the open state.
Setting it to the closed state with Javascript happened a fraction of a second
after page load. This caused an unpleasant flicker as the whole page shifted up
and down as it loaded.

This commit changes the switcher to use the native HTML5 `details` and
`summary` elements[1].

This commit adds a polyfill from GOV.UK Elements for browsers which don’t
support `details`/`summary`.

1. http://html5doctor.com/the-details-and-summary-elements/
2016-01-19 11:45:18 +00:00
Nicholas Staples
a9fead0d82 Merge with master. 2016-01-19 09:49:01 +00:00
Chris Hill-Scott
81d4230b61 Page for adding a new service
This page is exactly the same as the page for adding your first service, save
the heading text.

So all this commit does is:
- set up two routes (`/add-service`, `/add-service/first`) for each of the two
  journeys and change the existing journeys to use the `/add-service/first`
  route
- add logic to show different heading text depending on the journey
- add a link to the new (`/add-service`) route in the service chooser dropdown
2016-01-18 11:03:25 +00:00
Nicholas Staples
4e2019c949 Work in progress, all tests passing and implemented mocks for services_dao. 2016-01-15 17:46:09 +00:00
Chris Hill-Scott
1e0f5c27b9 Add link to delete a template
This is a link not a button because:
- it’s less prominent—delete is an infrequent action
- it’s a two-step process, and only the second part changes any data (so it has
  a button)
2016-01-14 10:59:51 +00:00
Chris Hill-Scott
04b9c120d4 Add mocked service ID to all service-specific pages 2016-01-13 12:44:12 +00:00
Chris Hill-Scott
4cb535a2e1 Add progressive enhancement to service switcher
- by default, the menu is open
- if Javascript is enabled/loaded, the links are hidden, and visual cues (▶) to
  show that it can be opened are added
- clicking it opens and closes it
2016-01-12 11:47:02 +00:00
Chris Hill-Scott
732efd25c7 Refactor markup
Strips it down to only what’s necessary

As a separate commit for easier diffing.
2016-01-12 11:47:02 +00:00
Chris Hill-Scott
934ce51f2c Use user’s real name, not a placeholder 2016-01-12 11:47:02 +00:00
Chris Hill-Scott
7be32be70d Fix code whitespace
As a separate commit for easier diffing
2016-01-12 11:47:02 +00:00
Chris Heathcote
8dbf266e87 Design showing opened service switcher 2016-01-12 11:47:02 +00:00
Chris Heathcote
884e4e8057 Added in bar containing service name, user name/link to profile and sign out 2016-01-12 11:47:02 +00:00
Chris Hill-Scott
e8fe8c50ba Add a WTForms-compatible textbox macro
This macro:
- accepts a WTForm form field as a parameter
- renders a form field which follows the GOV.UK Elements patterns, both visually
  and in markup terms

It then changes any page which uses either:
- the old, non-WTForms macro or
- the old, WTFforms `render_field` macro

…to use this new macro and removes both of the old ones.

It also adds the option to display hint text above the textbox.
2016-01-11 15:20:00 +00:00
Rebecca Law
a860f713d2 Implementation of the new_password endpoint.
Found a way to create the token that does not need to persist it to the database.
This requires proper error messages, written by people who speak menglis good.
2016-01-11 12:23:07 +00:00
Chris Hill-Scott
4d10eec1e2 Rename submit_form component to page_footer
Submit form was
- a confusing name in itself
- not descriptive, because it also has an optional ‘back’ link

This commit also puts this component in as many pages as possible, stripping
out any hard-coded buttons and links.

It replaces any usage of buttons for ‘back’, because these are links, not
buttons (ie they don’t change any data).
2016-01-08 15:02:08 +00:00
Nicholas Staples
7001d8261d Fix for security hole with setting session['user_id'] before second factor of authentication has been authorised. 2016-01-07 12:43:10 +00:00
Nicholas Staples
0a4ea6ca2e Merge branch 'master' into provide_logout_link 2016-01-06 17:06:04 +00:00
Nicholas Staples
5905229714 Logout functionality and test added. 2016-01-06 16:40:38 +00:00
Nicholas Staples
6fc39d1814 Add in macro import to our template, not govuk_template 2016-01-06 11:37:59 +00:00
Chris Hill-Scott
3ed415fb75 Enhance message textbox by styling placeholders
Users can add placeholders to their messages, eg

> …your vehicle ((registration number))

when the message is sent, this gets replaced with the data the user uploads, eg

> …your vehicle LC12 BFL

We reckon that it will be useful to see that the placeholder has been
recognised, ie that its syntax is correct, before uploading any data.

We reckon that the best way to do this is by styling it differently to the rest
of the text that the user types.

This is not a trivial problem. There are two possible ways to do it:

1 Write a Google Docs-style text rendering engine, which completely replaces
  the native HTML `<textarea>` with a custom control, and programme what should
  happen when the user types something that looks like a placeholder, or
  presses an arrow key, or makes a selection, or…
2 Leave the `<textarea>` in place, unmodified, and duplicate layers in front
  of/behind it to visually replace a placeholder with the blue lozenge

Unsurprisingly, this commit implements 2.

There are four layers. Each layer contains live-updated copy of the text in the
textbox, and each is styled differently:
- one layer behind the textbox to make the blue background
- the textbox itself
- a layer with the white text, which overlays the black text of the textbox
- a layer with an inner shadow to knock back the brackets

This is because of some interesting limitations:
- The text in the foreground and background must occupy the same physical space,
  so no deleting characters from the duplicated layers
- Words can’t be split up into multiple elements,
  eg `<span>((</span>regist…`:—this results in slightly different kerning to
  `((regis…`, which messes up the alignment of the layers
- The textbox can’t be completely overlapped with a block of colour, because
  the cursor disappears behind it. Trying to edit text when you can’t see the
  cursor is hard.

Implementation

Technically this makes use of Paul Hayes work on Javascript modules in the
GOV.UK frontend toolkit[1].

It also makes use of the `oninput` event to detect changes to the textbox’s
contents. This is much more performant than `onkeydown`, `onpaste`, etc. Without
it the delay between user input and the layers all updating is too slow and you
see misalignment of the layers.

1. https://github.com/alphagov/govuk_frontend_toolkit/pull/227
2016-01-06 09:39:42 +00:00
Chris Hill-Scott
5ebeec08ae Use a Node-based tools for handling assets
…or how to move a bunch of things from a bunch of different places into
`app/static`.

There are three main reasons not to use Flask Assets:
- It had some strange behaviour like only
- It was based on Ruby SASS, which is slower to get new features than libsass,
  and meant depending on Ruby, and having the SASS Gem globally installed—so
  you’re already out of being a ‘pure’ Python app
- Martyn and I have experience of doing it this way on Marketplace, and we’ve
  ironed out the initial rough patches

The specific technologies this introduces, all of which are Node-based:
- Gulp – like a Makefile written in Javascript
- NPM – package management, used for managing Gulp and its related dependencies
- Bower – also package management, and the only way I can think to have
  GOV.UK template as a proper dependency

…speaking of which, GOV.UK template is now a dependency. This means it can’t be
modified at all (eg to add a global `#content` wrapper), so every page now
inherits from a template that has this wrapper. But it also means that we have a
clean upgrade path when the template is modified.

Everything else (toolkit, elements) I’ve kept as submodules but moved them to a
more logical place (`app/assets` not `app/assets/stylesheets`, because they
contain more than just SASS/CSS).
2016-01-05 13:12:35 +00:00
Chris Hill-Scott
a5f4580a7f Get SASS compilation working
Main thing that was missing was including the main CSS file in the template.

There are a few hacky bits here, like moving the whole of toolkit inside the
stylesheets directory.

Would arguably be cleaner using something that isn’t Flask Assets, but that’s
something for later.
2015-12-11 09:48:59 +00:00
Chris Heathcote
12cbc04080 Changed main GOV.UK link depending on whether user is logged in or not
Goes to / for not logged in, /dashboard for logged in.
2015-12-07 16:18:05 +00:00
Chris Heathcote
da80013ec9 Adding beta phase banner 2015-12-03 16:01:00 +00:00
Chris Heathcote
701ce482d4 Create base forms for registration and sign in
Created routes and forms for registration, sign in, and registration
from an invite.
Also tidied up assets folder, removed copy of fronted toolkit.
2015-11-26 10:18:37 +00:00