Hide and Restore TC Direct Links

These instructions explain how to temporarily hide the TC Direct buy links on the local tcmc.se website, then restore them when tcdirect.se goes live.

Keep the Python script!

This page is only an instruction sheet. You also need the toggle_buy_links.py script supplied separately. The commands below assume it is saved in your Downloads folder.

Back up your website folder before running the script. The script edits your local HTML files directly.

1. File locations

Website folder:

/Users/mark/Dropbox/TC Websites/SE Website

Python script:

/Users/mark/desktop/toggle_buy_links.py

Keep the double quotes around paths in the commands below. They allow Terminal to handle folder names containing spaces.

2. Open Terminal

  1. Press Command + Space to open Spotlight.
  2. Type Terminal and press Return.

To check that Python 3 is available, enter:

python3 --version

You should see a Python 3 version number. If Python 3 is not installed, install it from python.org, then reopen Terminal.

3. Hide the links now

Copy this entire command, paste it into Terminal, and press Return:

python3 "/Users/mark/desktop/toggle_buy_links.py" hide "/Users/mark/Dropbox/TC Websites/SE Website"

The script will:

Both the link and its text will disappear from the displayed page. Running the hide command again will not hide the same links twice.

Check a few local pages in your browser, then upload the modified HTML files to tcmc.se. Running this script does not update the live website automatically.

4. Restore the links when TC Direct goes live

Open Terminal again. Copy and run this command:

python3 "/Users/mark/desktop/toggle_buy_links.py" restore "/Users/mark/Dropbox/TC Websites/SE Website"

The script will replace its specially marked comments with the original links. It does not remove ordinary HTML comments.

Check that the links are visible and work correctly, then upload the restored HTML files to tcmc.se.

5. Important reminders

6. Troubleshooting paths on a Mac

“Can't open file” or “No such file or directory”: Check that the script really is in Downloads and is named toggle_buy_links.py, not toggle_buy_links.py.txt.

“The website folder does not exist”: Check the website folder path, and keep the surrounding double quotes.

Handy tip: Drag a file or folder from Finder into Terminal to insert its path with spaces handled automatically. Terminal may use backslashes before spaces instead of surrounding quotes; that is normal.

Because the commands above use full paths, you can run them from any current folder in Terminal.