Now that we have fancy tricks to make awesome CSS, let’s take a look at the
interface and update it a bit. While we can make our own, let’s use as much of
the Twitter Bootstrap styles as we can.
Transcriptions Page
Right now the transcriptions are in a table with a cell for every property of
the object. One way to make this easier to navigate would be to make each image
the primary visual for the page in a grid. We can do this with some helpers
Rails provides, as well as some styles that Bootstrap provides. Open
app/views/transcriptions/index.html.erb. We want to update the file to first
use Bootstrap’s layout options, specifically the idea of rows and
columns.
Before you start your server back up, what do you expect to happen? How should
this be different? How many different helper methods are getting used here?
Show View
The transcription#show view needs some work too. We can make this look a lot
better, separating the metadata (title and description) from the actual content
(image and transcription). We can also update the notice (for when a new item
has been created, or a current item has been updated). Open
app/views/transcription/show.html.erb and replace with the following:
Ok, hands off the keyboard. What is going on here? What is simple_format?
What is the unless notice.nil? doing at the top? Why is there all that
additional markup around the notice?
Forms
Let’s take a look at the form partial for transcriptions. Open
app/views/transcriptions/_form.html.erb and make it read as follows:
This code adds HTML 5 placeholders to the form fields. Anything else
interesting going on here? Go back to your browser and add a new transcription,
then edit it. Does this feel right?
You may notice that in the transcription#edit view, you never actually see
the image, you can only ever upload a new image. We need a new view for this.
For now, let’s make a new partial that will allow users to edit the title,
description, but see the image that was uploaded to create a transcription.
Create a new file app/views/transcriptions/_edit_form.html.erb and add the
following:
If you look at the view code for transcriptions#new and
transcriptions#edit, you’ll notice they both include the partial form.
We need to update app/views/transcription/edit.html.erb to render the
edit_form partial:
It’s time to explore your application a bit. Are there other things you could
do to make the application easier to navigate?
Have you forgotten anything at this point? Starts with G, rhymes with
hit…
Summary
In this exercise, we implemented some basic styles that the Twitter Bootstrap
framework provides. In many projects, the design process takes as much (if not
more) time to get to a point where the front-end is thought through to ensure
users can perform the intended actions of an application with little (or no)
help from you, the developer. If you’re interested in this component of the
software lifecycle, I would encourage you to consider taking a course in web development and design principles. Sometimes we even have them at HILT!