Skip to content

Commit

Permalink
Merge pull request #49 from smcgov/upstream-updates
Browse files Browse the repository at this point in the history
Upstream updates
  • Loading branch information
monfresh committed Sep 4, 2014
2 parents 487bc95 + 2a7be13 commit e0ddd49
Show file tree
Hide file tree
Showing 498 changed files with 26,131 additions and 59,304 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
/spec/screenshots/
/spec/tmp/*

# Ignore metric_fu directory
/specifications

# Ignore yard docs and db docs
/doc/*
.yardoc/*
Expand All @@ -46,7 +43,6 @@
/public/cache
/public/stylesheets/compiled
/public/system/*
/public/assets/*
/cache
/gems
rerun.txt
Expand Down
3 changes: 3 additions & 0 deletions .haml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters:
LineLength:
max: 351
29 changes: 29 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
AllCops:
Include:
- 'Gemfile'
- 'Rakefile'
Exclude:
- 'bin/*'
- 'db/seeds.rb'
- 'config/initializers/generators.rb'
- 'config/unicorn.rb'
- 'config/compass.rb'

# Allow dots at the end of lines when chaining methods
# that span multiple lines
DotPosition:
Enabled: false

LineLength:
Enabled: false

Documentation:
Enabled: false

MethodLength:
CountComments: false
Max: 10

ClassLength:
CountComments: false
Max: 100
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.1.2
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
bundler_args: "--without development:production"
install: bin/wad
script: bundle exec rspec
language: ruby
rvm:
- 2.1.1
services:
before_script:
- 2.1.2
notifications:
campfire:
rooms:
Expand All @@ -17,5 +18,7 @@ deploy:
secure: occyVXAT6AznUMneNmA9AsxHxnto+HUxwBoNpMiAAm0OCj3PtGfvvQho94hGwnZiAfsbTt3Y6NyGLspQCJuSsazgx2FrXuG3h/XlyyqjZ6EplG1leWSnp9rYic2q1itUe6dqRZWW7FjNIee0iVs7CxGLR/vaYoDzxYDegZ1y9p4=
env:
global:
- secure: E7pU+I2VhRfS3g3Fn8sWNF3ecrMG0PkNJ4CMrIwV0mnhtTQGIcI2k6MrMPYcms04nCn8lmd6iH+ey8Yjovva3O2WmttRoEpCNORd6oGQYkSafLK+QyAJYSJ6tZ+aIHHiJKQ+z6O13LlaLNHEJqLq0SQ9uYcF+ZWDx58u0Ed/v5Q=
- secure: A56coF7dN9fnPqX1O5JELVPl+/FnocWH+C/0W60gtQzOocWizNFQW7ri002IUPIojYh4b2XZqEtWZ20RdXdaNc7+YBC86SAqBd/WxbhlYXGEOOs14lnrSk/SezHUGjBm/ZmYoRXjH5VoXtqn95LRPseuVbLkli0yCAlUz/+lvZg=
- S3_BUCKET_NAME=gems-for-travis
- OHANA_API_ENDPOINT=http://smc-ohana-api-test.herokuapp.com/api
- secure: AQX/bYCvfEqZOAxXv3u4TIFdAvyCqFS0pnpmL0gPEPTI6SurTzpzC/NE6fKMc7In23N83kp25iigajiz9ZLk1QTr3Ko5LKNxsLfTCT4Pg2xmTx9eU0GvWO3ghx2iq+Dh7v43VQDRXd/q2ywW+rfN2t/fjimS0wbLWu7++UmIOjU=
- DOMAIN_NAME=lvh.me
77 changes: 47 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ In the spirit of open source software, **everyone** is encouraged to help
improve this project.

### Ways *you* can contribute:
* by installing and testing the software
* by reporting bugs
* by suggesting new features
* by suggesting labels for our issues
* by writing or editing documentation
* by writing test specifications
* by writing code (**no patch is too small**: fix typos, add comments, clean up
inconsistent whitespace)
* by refactoring code
* by closing [issues][issue_tracker]
* by reviewing patches
* by [installing and testing the software][install_instructions]
* by [using the issue tracker][issue_tracker] for...
* reporting bugs
* suggesting new features
* suggesting labels for our issues
* by improving the code through:
* writing or editing documentation
* writing test specifications
* refactoring the code (**no patch is too small**: fix typos, add comments,
clean up inconsistent whitespace).
* reviewing [open Pull Requests][open_prs]
* by [donating to Code for America][donate]

### Reporting a bug or other issue
We use the [GitHub issue tracker][issue_tracker] to track bugs and feature
We use the GitHub issue tracker to track bugs and feature
requests. To submit a bug report or feature request:

1. [Browse][issue_tracker] or [search][issue_search] our issues to make sure
it hasn't already been submitted.
1. **[Browse][issue_tracker] or [search][issue_search] our issues** to make
sure your issue hasn't already been submitted.

2. When submitting a bug report, it's helpful to include any details that may
be necessary to reproduce the bug, including:
2. **[Submit an issue][new_issue]**.
If you're submitting a bug report, it's helpful to include any details that
may be necessary to reproduce the bug, including:

- a screenshot
- your operating system (Windows 7, Mac OSX 10.9.2, etc.)
Expand All @@ -40,34 +41,50 @@ To submit a code change to the project for review by the team:

1. **Setup:** Make sure you have the [prerequisites installed][prerequisites]
on your computer.
1. **Fork:** [Fork this repository and clone it on your computer][fork].
2. **Install Dependencies:** From the root directory of the app, run `bundle`.
3. **Branch:** [Create a topic branch][branch] for the one specific issue

2. **Fork:** [Fork this repository and clone it on your computer][fork].

3. **Install Dependencies:** From the root directory of the app, run `bundle`.

4. **Branch:** [Create a topic branch][branch] for the one specific issue
you're addressing.
4. **Write Specs:** Add specs for your unimplemented feature or bug fix in the

5. **Write Specs:** Add specs for your unimplemented feature or bug fix in the
`/spec/` directory.
5. **Test to fail:** Run `rspec`. If your specs pass, return to **step 3**.
In the spirit of Test-Driven Development, you want to write a failing test
first, then implement the feature or bug fix to make the test pass.
6. **Implement:** Implement your feature or bug fix. Please follow the

6. **Test to fail:** Run `spring rspec`. If your specs pass, return to
**step 5**. In the spirit of Test-Driven Development, you want to write a
failing test first, then implement the feature or bug fix to make the test
pass.

7. **Implement:** Implement your feature or bug fix. Please follow the
[community-driven Ruby Style Guide][style_guide]*.
7. **Test to pass:** Run `rspec`. If your specs fail, return to **step 5**.
8. _(If applicable)_ **Clean up JavaScript code:** Run `rake jshint` to check

8. **Test to pass:** Run `script/test` to run the test suite in addition to the
style checkers. If your specs fail and/or style offenses are reported, return
to **step 7**.

9. _(If applicable)_ **Clean up JavaScript code:** Run `rake jshint` to check
JavaScript code quality.
9. **Commit changes:** Add, commit, and push your changes.
10. **Pull request:** [Submit a pull request][pr] to send your changes to this

10. **Commit changes:** Add, commit, and push your changes.

11. **Pull request:** [Submit a pull request][pr] to send your changes to this
repository for review.

_*If you use Sublime Text, please make sure to set your tab indentation to 2
spaces. We also highly recommend you use the [TrailingSpaces][trailing_spaces]
plugin and set it to [Trim On Save][trim_on_save]._

[install_instructions]: https://github.com/smcgov/SMC-Connect/blob/master/INSTALL.md
[open_prs]: https://github.com/smcgov/SMC-Connect/pulls?q=is%3Aopen+is%3Apr
[donate]: http://codeforamerica.org/support-us/
[issue_tracker]: https://github.com/smcgov/SMC-Connect/issues
[issue_search]: https://github.com/smcgov/SMC-Connect/search?ref=cmdform&type=Issues
[prerequisites]: https://github.com/smcgov/SMC-Connect#prerequisites
[prerequisites]: https://github.com/smcgov/SMC-Connect/blob/master/INSTALL.md#install-prerequisites
[new_issue]: https://github.com/smcgov/SMC-Connect/issues/new
[fork]: http://help.github.com/fork-a-repo/
[branch]: https://help.github.com/articles/fork-a-repo#create-branches
[branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository
[style_guide]: https://github.com/bbatsov/ruby-style-guide
[pr]: http://help.github.com/send-pull-requests/
[trailing_spaces]: https://github.com/SublimeText/TrailingSpaces
Expand Down
105 changes: 105 additions & 0 deletions CUSTOMIZE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Customizing Ohana Web Search

## Environment variables
Inside the `config` folder, you will find a file named `application.example.yml`.
Copy its contents to a new file called `application.yml` in the same directory.
Read through the documentation to learn how you can customize the app to suit
your needs.

If you're planning on deploying the app to Heroku, you can set all the required environment variables in production by running the following command:

```
$ script/setup_heroku -a your_app_name -o your_api_endpoint
```
`your_api_endpoint` is the URL to your instance of Ohana API, such as `http://ohana-api-demo.herokuapp.com/api`. `your_app_name` is your Heroku app's name. Read the [script](https://github.com/codeforamerica/ohana-web-search/blob/master/script/setup_heroku) for more details about what it will install.

The script only sets required environment variables. To set optional environment variables on Heroku, such as `GOOGLE_ANALYTICS_ID`, you'll need to set them manually. Read through `application.example.yml` to learn about all the optional variables you can set, and read the Heroku documentation to learn how to [set Heroku configuration variables](https://devcenter.heroku.com/articles/config-vars).

By default, the script assumes you will be using a `*.herokuapp.com` domain name. If you will be using a custom domain name, you will need to set the `CANONICAL_URL` and `DOMAIN_NAME` variables manually. Read `application.example.yml` for more details about those variables.

## Website settings
Inside the `config` folder, you will find a file called `settings.yml`.
In that file, there are many settings you can, and should, customize.
Read through the documentation to learn how you can customize the app to suit
your needs.

## Localization
Inside the `config/locales` folder, you will find a file called `en.yml`.
In that file, you can customize much of the user-facing text on the website.
Most of the text should be ready to go, but there is one specific setting
you should customize: the [location](https://github.com/codeforamerica/ohana-web-search/blob/master/config/locales/en.yml#L28) value under `branding`.

## Pagination
The pagination of search results is handled by the [Kaminari](https://github.com/amatsuda/kaminari) gem.
To configure the functionality, make changes in [kaminari_config.rb](https://github.com/codeforamerica/ohana-web-search/blob/master/config/initializers/kaminari_config.rb).
To change the informational text about the search results, visit the [page_entries_info](https://github.com/codeforamerica/ohana-web-search/blob/master/config/locales/en.yml#L46-55) section in `en.yml`.
To change the labels for the navigation buttons, visit the [pagination](https://github.com/codeforamerica/ohana-web-search/blob/master/config/locales/en.yml#L98-103) section in `en.yml`. To change the markup, make changes to the partials in [app/views/kaminari](https://github.com/codeforamerica/ohana-web-search/tree/master/app/views/kaminari).

To test the pagination feature, you might find it handy to force a particular
number of results per page by adding the `per_page` parameter to the end of the
URL. For example: [http://ohana-web-search-demo.herokuapp.com/locations?utf8=%E2%9C%93&keyword=&location=&per_page=5](http://ohana-web-search-demo.herokuapp.com/locations?utf8=%E2%9C%93&keyword=&location=&per_page=5)

## Map marker graphics
The root `graphics` folder contains source files for images in the application. In this directory, you can find an Adobe Illustrator source file for the Google map marker graphics. With this file you can adjust the map marker appearance by making changes and exporting and overwriting the files in `/app/assets/images/markers`. The Google map appears on the search results and location details pages.

## Adding JavaScript code
Ohana Web Search doesn't use the default `application.js` manifest file for loading JavaScript files that may be
found in a typical Rails app. Instead, it uses a modular JavaScript pattern through the [requirejs-rails gem](https://github.com/jwhitley/requirejs-rails). More information about this setup can be found in the modified
[application.js][applicationjs] file and the [RequireJS configuration][requirejsconfig] file.

[applicationjs]: https://github.com/codeforamerica/ohana-web-search/blob/master/app/assets/javascripts/application.js
[requirejsconfig]: https://github.com/codeforamerica/ohana-web-search/blob/master/config/requirejs.yml

## Allow search engines to index your site
Search engines are blocked by default so that they don't index your site until it's ready.
Once your site is serving your own data from your own instance of Ohana API, and once you're satisfied with the content on your site, then you can invite search engines to index your site by commenting out lines 4 and 5 in [public/robots.txt](https://github.com/codeforamerica/ohana-web-search/blob/master/public/robots.txt#L4-5), like so:
```
# User-agent: *
# Disallow: /
```

## Caching
Depending on how many visitors your app gets, you might want to improve the performance of the app by configuring two types of caching: one is caching the API requests via `Faraday::HttpCache` in [config/initializers/ohanapi.rb](https://github.com/codeforamerica/ohana-web-search/blob/master/config/initializers/ohanapi.rb), and the other is caching the entire results page and/or location details page.

API request caching is turned on by default, and will prevent the app from making the same API request for a [period of time specified by the API](https://github.com/codeforamerica/ohana-api/blob/master/config/application.example.yml#L82-89). By default, that is set to 5 minutes. That means that if a location's info has changed on the API side, if Ohana Web Search had already requested that same location, the latest data changes won't appear in Ohana Web Search until 5 minutes have passed since the first request was made.

As for page caching, it is disabled by default. If you determine that you need to cache pages, you can turn it on by setting the `ENABLE_CACHING` environment variable on your production server to `true`. If you're using Heroku, you can set it like this:
```
$ heroku config:set ENABLE_CACHING=true -a your_heroku_app_name
```

When page caching is enabled, it will store the page in Memcached via the [MemCachier add-on on Heroku](https://addons.heroku.com/memcachier) (by default) so that the next time any browser requests that same page, it will be served from cache instead of the server. In addition to the app storing the page in Memcached, most modern browsers will also store the page in their cache, and will send an `If-Modified-Since` date in the Request Headers to ask the server if a newer version exists.

Because the `If-Modified-Since` date is based on the `updated_at` field returned by the API, any changes you make to the page will not appear on the website as long as the `updated_at` field hasn't changed, and as long as the browser is still fetching the page from its cache. In order to invalidate the cache for your site visitors, you'll need to flush the MemCachier cache, and update the `updated_at` field for all of the locations in the API.

To flush the MemCachier cache on Heroku, run the following command:

heroku run -a your_app_name rails runner -e production Rails.cache.clear

To update the `updated_at` field, follow these steps:

1. Run the Rails console for your instance of the Ohana API (not Ohana Web Search) on Heroku:

```
$ heroku run rails c -a your_api_app_name
```

2. Update all locations:

```
> Location.find_each(&:touch)
```

3. Quit the console:

```
> quit
```

Note that this is only one caching solution. For other caching strategies, visit the following resources:

[https://devcenter.heroku.com/articles/http-caching-ruby-rails](https://devcenter.heroku.com/articles/http-caching-ruby-rails)

[https://devcenter.heroku.com/articles/caching-strategies](https://devcenter.heroku.com/articles/caching-strategies)

[http://railscasts.com/episodes/321-http-caching](http://railscasts.com/episodes/321-http-caching)
Loading

0 comments on commit e0ddd49

Please sign in to comment.