tardate / trumpeter_catalog

Fast and simple skin for the Trumpeter model catalog

Home Page:https://trumpeter-catalog.tardate.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trumpeter Catalog Skin

A fast and simple skin for the Trumpeter model catalog, using some nokogiri magic. Currently available to browse online here.

Here's a quick demo..

clip

Notes

Trumpeter 小号手公司 is one of the main scale model manufacturers in China, and their website is not only available in English, but reasonably informative.

It is however very slow, a pain to search, and frequently down or inaccessible.

This is a little weekend project to create a fast and searchable skin for the Trumpeter catalog.

Setup

The catalog runs locally and needs a working ruby installation - I'm using Ruby 2.7.2 but the code is not version-sensitive. Dependencies can be installed with bundler in the usual way, then you are good to go:

bundle install

Caching the Catalog

The ./update_cache.rb script builds a local cache of the Trumpeter catalog. NB: this is sensitive to major changes in the Trumpeter web site, but for now works fine.

$ ./update_cache.rb
[Load Product Pages][2020-12-06 21:29:24 +0800] loaded
[Load Products][2020-12-06 21:29:24 +0800] loaded
[Load Product Image][2020-12-06 21:29:24 +0800] loading cache/images/09592.jpg with a 1 second grace period delay
[Load Product Image][2020-12-06 21:29:24 +0800] loading cache/images/09580.jpg with a 1 second grace period delay
...

Running the Catalog

After updating the cache, the index.html presents a very snappy searchable and filterable listing of the catalog. It's a simple web page using some basic Bootstrap and Datatables features with a little custom javascript.

Here's an example, with a simple search applied. Each entry has links to the main Trumpeter page as well as search links for the product on AliExpress and Google.

file_example

Note: the catalog is loaded from JSON file, which presents a security issue if the skin/index.html is loaded locally as a file in a browser.

In Firefox, the security issue can be overcome by disabling the security.fileuri.strict_origin_policy preference in about:config

Running with Sinatra

I've defined a simple Sinatra app in app.rb that can be used to serve the catalog locally over HTTP, avoiding the browser limitations with loading the JSON data file. Run it with:

$ ruby app.rb
== Sinatra (v2.1.0) has taken the stage on 4567 for development with backup from Thin
2020-12-06 23:31:57 +0800 Thin web server (v1.8.0 codename Possessed Pickle)
2020-12-06 23:31:57 +0800 Maximum connections set to 1024
2020-12-06 23:31:57 +0800 Listening on localhost:4567, CTRL+C to stop
::1 - - [06/Dec/2020:23:32:06 +0800] "GET / HTTP/1.1" 302 - 0.0034
::1 - - [06/Dec/2020:23:32:06 +0800] "GET /index.html HTTP/1.1" 304 - 0.0103
...

sinatra_example

Credits and References

About

Fast and simple skin for the Trumpeter model catalog

https://trumpeter-catalog.tardate.com/


Languages

Language:Ruby 35.9%Language:HTML 32.6%Language:JavaScript 29.0%Language:CSS 2.5%