This is a dynamic spreadsheet guide for journalists. It contains the everyday skills needed in a newsroom, adopted to your platform, software version and language. Live demo: https://tusg.herokuapp.com
To install:
git clone https://github.com/jplusplus/tusg.git
cd tusg
npm install
Optionally, to make the Google Sheets integration work, you will also need to add a API key and either Memcached or MemCachier.
- Get an API key (json format with line breaks, and explicit
='s) for your Google Drive service account (see this guide for step by step insctuctions on how to do this). - Open the downloaded json file, and copy the private key to a separate text file.
- Replace
\nwith actual line breaks. - Replace
\u003dwith= export GOOGLE_PRIVATE_KEY="$(cat google_private_key.txt)"export [email protected]apt-get install memcached(Ubuntu) orbrew install memcached(OS X) to install Memcached.export MEMCACHIER_SERVERS=127.0.0.1:11211(depending on your server setup. This is the defult for many systems) to set the Memcached server.
To get started:
gulp develop
gulp develop will set environment variables to defaults and start the app in development mode. You should now be able to access the site at localhost:3000
Each pug file in views/chapters corresponds to one chapter in the guide. Just edit the pug files, and reload the page.
In your chapter files, you can access a number of variables and helper functions, e.g.:
These are accessed like this:
if os == "MacOS"
p Character encoding can sometimes be an issue when importing CSV files.or inline like this:
p The bitwise AND function is written #{version < "Excel 2013" ? "with an ugly hack using SUBSTITUTE" : "BITAND"} in Excel.os: Operating system, e.g.Windows.software: E.g.Excel.version: E.g.Excel 2010language: Interface language for the software, e.g.Swedishlocale: Locale settings for the workbook, e.g.sv-SE.
These are accessed like this: !{f()}, eg:
p Use the function !{f("=MID()")} to extract a substring from a string, like this: !{f('=MID(A1, FIND("-", A1), 6)')}.f(): Translates a spreadsheet function, and uses the right argument delimiter (comma och semicolon). E.g.!{f("=LEFT(A1, 4)")}=>=VÄNSTER(A1; 4)t(): Translates a localized string. E.g.!{t("TRUE")}=>SANTmenu(): Translates an option or a menu path, and formats is like nicely. E.g.!{menu("Format", "Cells")}=>Formatera > Cellerkey(): Translates keyboard shortcut to the current OS. E.g.!{key("Ctrl", "A")}=>⌘-A
These are accessed like this: :image(name.png), eg:
:image(spreadsheet.png)
Here goes a caption to that imageimage(filename.png): Embeds an image from the/public/imgfolder. Usesmallas the second argument to inline a smaller, floating image. If the filename contains a comma you will have to enclose it in quotes.spreadsheet(KEY): Embeds an interactive spreadsheet, based on a Google Sheets identified by KEY, but localized.
export DEBUG=tusgto enable debug messagesexport NODE_ENV=developmentto run in development mode,export NODE_ENV=productionotherwise
To enable Google Sheets integration:
export GOOGLE_PRIVATE_KEY="$(cat google_private_key.txt)"private API key (json format with line breaks, and explicit='s) for your Google Drive service account (see this guide for step by step insctuctions on how to do this).export [email protected]export MEMCACHIER_SERVERS=127.0.0.1:11211
For Heroku, the corresponding commands would be:
heroku config:add DEBUG=tusgheroku config:add NODE_ENV=productionheroku config:add GOOGLE_PRIVATE_KEY="$(cat google_private_key.txt)"heroku config:add [email protected]heroku config:add MEMCACHIER_SERVERS=127.0.0.1:11211
- 0.0.1: First version