/wrhs

WRHS Website

Primary LanguageHTML

WRHS Website generator

Introduction

The purpose of this project is to automate generation of the WRHS website as much as possible, particularly the Trading Post stock listing. In general, you should never have to edit html or Java code directly. Another goal is to make it cross-browser and server-agnostic. To this end, I avoid JS, CMS, php etc. I do use some CSS but it should be viewable without (as yet untested).

It is a NetBeans 8.2 project for convenience, but it can be built from the command line without NetBeans.

It builds on Ubuntu with Java 7 or higher. Other new-ish linux systems should work.

Internally it uses Java, JBake, Apache Ant, and Asciidoctor.

TODO: Remove JBake. It is a large dependency and I am only using a tiny bit of it which can be replaced by AsciidoctorJ. I think.

TODO: (maybe) Generate the trading post pages using H2 and Ant. After all, it is just mucking about with CSV files.

Installation

  • Install Java (sudo apt-get install java)

  • Install Ant (sudo apt-get install ant)

  • Install Git (only required if you want to update the source) (sudo apt-get install git)

  • Install JBake (download and expand JBake.zip)

  • Extract from Github and copy or expand the entire wrhs folder next to the JBake folder. (You can put it elsewhere, but you will then have to edit the JBake path in build.xml.)

Build

Important
You only need to do this if you have changed the Java code. This should be very rare. See Edit the format of Trading Post product listings.
  • Open a command window and change directory to wrhs/. Type:

    ant build

Preview

  • Start a local web server:

    To use JBake, open a command window and change directory to wrhs/. Type:

    ant run

    Or if you have python installed, open a command window and change directory to wrhs/output/. Type:

    python -m SimpleHTTPServer 8080
  • Open a browser and point it to localhost:8080. The website will appear, served directly from the output folder.

Upload to the public server

  • Open a command window and change directory to wrhs/. Type

    ant clean run deploy

    You will be prompted for the username and password.

Update the stock list

  • Download the 2 CSV files from EPOS, and put them in folder wrhs/tradingpost/, overwriting the current ones.

  • Open a command window and change directory to wrhs/. Type

    ant
  • Watch the screen for any errors. Particularly look for any type of Exception.

    • The most common cause of FileNotFoundException is a missing file. Did you accidentally delete one or rename it?

    • The most common cause of IOException is a file is open in another application such as PDF or Excel. Close them.

    • The most common cause of DataException is new data in the product file. To add a new category, see [addcategory].

Add a product in an existing category

To make a new product appear on the trading post pages:

If you want, add a thumbnail: The file type can be either .png or .jpg. The file size should be less than 20K (5K is better). Add the photo to "assets/pics/" in a sensible subfolder.

Add a line to extrainfo.csv:

  1. Open the file using Excel, Calc, or a text editor.

  2. Set "productid" to the product id exactly as it is in the EPOS file.

  3. For your own sanity, copy the description column as well.

  4. Set "page" to the group you want it to appear on. Create a new page by typing a different title, or reuse one of the others.

  5. Set "show" to 1.

  6. If you have a thumbnail for it (or want to re-use one) add it the the image column.

  7. If you want to add any other helpful stuff, put it in the info column. If this column has anything in it, it is added as a tooltip to the product name.

Preview the website to make sure that the image appears correctly (Preview).

Show or hide an item in the trading post

To be visible, the item must be listed in the imagemapping.csv file (Add a product in an existing category).

You can switch it off temporarily without deleting it by setting column "show" to 0.

Add a meeting document

  • Copy the file to wrhs/assets/meetings/.

  • Add a new row to the table in wrhs/content/society/meetings.adoc following the existing examples.

  • Preview the website (Preview).

  • Make sure that your new documents are listed.

  • Click each document link to make sure it works.

  • Upload the website (Upload to the public server).

Add a newsletter in the current year (YYYY)

  • Create a thumbnail for it (png, width 212 pixels, height 300 pixels).

  • Make sure that the file names are like yyyy-mm.pdf and yyyy-mm.png.

  • Put the thumbnail and the pdf file in wrhs/assets/newsletters/YYYY.

Add a newsletter for a new year

The website is prepared up to 2020. To make future years visible, edit the ALL_NEWLETTERS string in nbbuild.xml.

For years after 2020 (for example 2021):

  • Create a folder wrhs/assets/newsletters/2021/.

  • Create a folder wrhs/content/newsletters/2021/.

  • Edit wrhs/nbbuild.xml and add a new line to the "generate" target following the example of the others.

  • Add the newsletter as above (Add a newsletter in the current year (YYYY)).

Add an event

Create a pdf and a matching thumbnail (.png) and drop them in wrhs/assets/events/ in the same way as newletters (Add a newsletter in the current year (YYYY)).

Files are presented in alphabetical order, so if you start the filename with the date, they will appear in date order.

Change other content

Most of the content is generated from asciidoc (.adoc) files (http:///asciidoctor.org).

Edit the file in any text editor (NOT Word) following the existing example, then preview (Preview) and upload (Upload to the public server).

File Generated page

wrhs/content/join.adoc

Join

wrhs/content/links.adoc

Links

wrhs/content/tips.adoc

Horticultural tips

wrhs/content/about.adoc

Society→About

wrhs/content/society/workparties.adoc

Society→Work parties

wrhs/content/society/meetings.adoc

Society→Meetings. See Add a meeting document.

wrhs/content/society/contacts.adoc

Society→Committee

wrhs/content/tips/

Not used (future)

Change the theme

Edit files in wrhs/assets/css/. You are on your own. (but theme needs work).

Edit the format of Trading Post product listings

These are done in Java. See the Builder class in wrhs/src/.

Edit the format of automatically indexed folders

Eg events, newsletters.

These are done in Java. See the CatalogueFolder class in wrhs/src/.

Commit changes

If you have a checkout already, make sure that it is up to date with master:

git fetch upstream

git checkout master

git merge upstream/master

git push origin master

(You should probably do this before you start making any changes as well)

Now you can commit your changes. The Git gui is probably easier than the command line:

git gui