generate is a tool to generate static HTML for browsing Redbubble works.
Then, in a console execute:
git clone git://github.com/duncan-bayne/redbubble.git
gem install bundler
generate should install on pretty much any recent UNIX or UNIX-like operating system, and Microsoft Windows. I've tested it on 64-bit Linux Mint 17.2 (Rafaela).
Generates static HTML files for browsing images. Usage: generate [options]
-c, --clean First delete all HTML files from the output directory; default is false
-i, --input INPUT Specify the XML file containing work and EXIF data
-o, --output-dir OUTPUT Specify the directory in which to create static HTML files
$ mkdir tmp
$ ./generate -i spec/fixtures/works.xml -o tmp
The above will create a directory called
tmp, and generate the static HTML files inside it. You can then browse the index with your favourite browser:
$ firefox tmp/index.html &
I developed generate in an exploratory fashion. You can see the commit log for how I proceeded.
I chose to build an ActiveRecord-based application upon an in-memory SQLite3 database. This is slightly slower than a naive implementation, but runs well on 100,000-work datasets, and could easily be extended in a variety of ways. Potential improvements include using a more conventional database (e.g. PostgreSQL) for very large datasets, or implementing the database population code in a language more suited to fast XML processing than Ruby.
New issues can be logged on the Issues page.
This is the directory structure of the application, with a few very important files identified:
├── doc Documentation from Redbubble
├── generate The application executable
├── script Utility scripts
│ ├── fixtures Fixture files for specs
│ ├── lib Specs for library classes (only one for now)
│ ├── models Specs for models
│ ├── support Shared examples for specs
│ └── views Specs for view classes
├── db.rb Contains database setup and schema
├── lib Library classes
├── models Model classes
├── templates ERB templates from which HTML is generated
└── views View classes
Depending upon the time available and the background of the intended users, some of those assumptions could easily be challenged. E.g. Windows users are not used to case sensitivity or silent success.
You can use the
script/generate_fixture script to generate arbitrarily large work XML files for testing. E.g.:
$ ./script/generate_fixture -w 1000 > spec/fixtures/works-1k.xml
$ time ./generate -i spec/fixtures/works-1k.xml -o tmp
./generate -i spec/fixtures/works-1k.xml -o tmp 2.14s user 0.13s system 100% cpu 2.275 total
Running generate against a 100,000 work fixture should take around six and a half minutes on a development-spec laptop.
Specs, profiling and quality checks are automated through rake. E.g. to display a list of all tasks:
$ rake -T
rake clean # Clean all tempfiles and test reports
rake default # Runs all specs and quality tests
rake documentation # Generates HTML documentation from Markdown files
rake profile # Profiles generation from 10,000 works
rake roodi # Run Roodi against all source files
rake specs # Run RSpec code examples
All original code and documentation is Copyright © Duncan Bayne, and licensed under the WTFPL.
The requirements, sample works XML and template are Copyright © Redbubble Pty. Ltd. All rights reserved.