← Back to the gamebug or idea?Terrapin Trail//Code BibleIIhow the game works, archive to van
Reel 14 · 5 min read

Hashtags and share links

How every tour gets a unique name, and how shared links remember where they were posted.

Every tour has a hashtag, like #TTGD77Apr: Terrapin Trail, Grateful Dead, the tour that started in April 1977. The hashtag is the tour's name, its link and its leaderboard all at once.

Making the name

The band part is the band's initials, or the whole name if it's one word:

●tags.py : 21–31trace ↗
21def band_abbrev(band: str) -> str:
22    """'Grateful Dead' -> 'GD', 'String Cheese Incident' -> 'SCI', 'Phish' -> 'Phish'."""
23    words = [w for w in re.split(r"[^A-Za-z0-9]+", band) if w]
24    if words and words[0].lower() == "the" and len(words) > 1:
25        words = words[1:]
26    if not words:
27        return "X"
28    if len(words) == 1:
29        w = words[0]
30        return (w[0].upper() + w[1:])[:10]
31    return "".join(w[0].upper() for w in words)[:6]
Grateful Dead becomes GD, String Cheese Incident becomes SCI, Phish stays Phish.

Two different bands can share initials, so the first time a tour is listed its tag is written down in the shared store. If someone else already has it, a letter is added to make it unique.

Concept: "unique identifier". A unique identifier is a name that points at exactly one thing. Your email address is one. A tour's tag has to be one too, or a shared link could open the wrong tour.

Links that know where they came from

When you share a tour, the link carries a few extra labels on the end, called UTM tags: where it was posted (X, Instagram, a text message), and who shared it. When someone opens the link, the server counts the visit under that source:

●runner.py : 264–288trace ↗
264    def tag_landing(tag: str) -> BaseResponse:
265        """A shared tour link: count where the visit came from, then open that tour."""
266        parts = tags.split(tag)
267        if not parts:
268            return redirect("/")
269        base, code = parts
270        code = dna.encode(dna.decode(request.args.get("dna") or code))
271        info = tour_info(base)
272        if not info:
273            return redirect("/")
274        base = info.get("tag", base)
275        full = tags.full_tag(base, code)
276        source = (request.args.get("utm_source") or "direct")[:40].lower()
277        store.zincr("src:" + full.lower(), source)
278        og = {
279            "title": f"#{full} - {info['band']} {info['year']} on Terrapin Trail",
280            "description": f"Drive the {info['band']} tour that started {info['start']}, "
281            "tape the shows, and beat the leaderboard. Real recordings from the Internet Archive.",
282            "type": "website",
283            "image": f"/og/{full}.png",
284        }
285        boot = {
286            "tag": base, "dna": code, "luck": request.args.get("luck"), "from": source,
287            "by": (request.args.get("utm_content") or "")[:24], "donate": DONATE_URL,
288        }
Someone opened a shared link: count where they came from, describe the tour for the link preview, then show them the tour.

That's how each leaderboard can show "where players came from".

Concept: "link preview". When you paste a link into a chat or a post, the app shows a little card with a title and description. It gets those from hidden tags in the page. The server writes those tags for each tour, so shared links look good.

The ideas to keep
  • A tour's hashtag is a unique identifier: its name, link and leaderboard.
  • Share links carry UTM tags, so the server can count where visitors came from.
  • Each shared tour gets its own link preview.