Skip to content

Commit b7fed22

Browse files
authored
Switch --gist output to gisthost.github.io with backward compatibility (#31)
> The --gist option should output a link to gisthost.github.io rather than gistpreview.github.io > > The JavaScript logic injected into the pages should now work for both of those domains, so it should detect if the page is being served on gisthost.github.io OR gistpreview.github.io - Update preview URLs to use gisthost.github.io instead of gistpreview.github.io - Update JavaScript to detect both gisthost.github.io and gistpreview.github.io domains for backward compatibility with existing links - Update help text and README to reference the new domain https://gisthost.github.io/?e33364139d39625eda6fbbe8527f5902/index.html
1 parent 6be0003 commit b7fed22

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ claude-code-transcripts json session.json --gist
102102
This will output something like:
103103
```
104104
Gist: https://gist.github.com/username/abc123def456
105-
Preview: https://gistpreview.github.io/?abc123def456/index.html
105+
Preview: https://gisthost.github.io/?abc123def456/index.html
106106
Files: /var/folders/.../session-id
107107
```
108108

109-
The preview URL uses [gistpreview.github.io](https://gistpreview.github.io/) to render your HTML gist. The tool automatically injects JavaScript to fix relative links when served through gistpreview.
109+
The preview URL uses [gisthost.github.io](https://gisthost.github.io/) to render your HTML gist. The tool automatically injects JavaScript to fix relative links when served through gisthost.
110110

111111
Combine with `-o` to keep a local copy:
112112

src/claude_code_transcripts/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,11 +1047,12 @@ def render_message(log_type, message_json, timestamp):
10471047
});
10481048
"""
10491049

1050-
# JavaScript to fix relative URLs when served via gistpreview.github.io
1050+
# JavaScript to fix relative URLs when served via gisthost.github.io or gistpreview.github.io
10511051
GIST_PREVIEW_JS = r"""
10521052
(function() {
1053-
if (window.location.hostname !== 'gistpreview.github.io') return;
1054-
// URL format: https://gistpreview.github.io/?GIST_ID/filename.html
1053+
var hostname = window.location.hostname;
1054+
if (hostname !== 'gisthost.github.io' && hostname !== 'gistpreview.github.io') return;
1055+
// URL format: https://gisthost.github.io/?GIST_ID/filename.html
10551056
var match = window.location.search.match(/^\?([^/]+)/);
10561057
if (!match) return;
10571058
var gistId = match[1];
@@ -1067,7 +1068,7 @@ def render_message(log_type, message_json, timestamp):
10671068
});
10681069
10691070
// Handle fragment navigation after dynamic content loads
1070-
// gistpreview.github.io loads content dynamically, so the browser's
1071+
// gisthost.github.io/gistpreview.github.io loads content dynamically, so the browser's
10711072
// native fragment navigation fails because the element doesn't exist yet
10721073
function scrollToFragment() {
10731074
var hash = window.location.hash;
@@ -1355,7 +1356,7 @@ def cli():
13551356
@click.option(
13561357
"--gist",
13571358
is_flag=True,
1358-
help="Upload to GitHub Gist and output a gistpreview.github.io URL.",
1359+
help="Upload to GitHub Gist and output a gisthost.github.io URL.",
13591360
)
13601361
@click.option(
13611362
"--json",
@@ -1443,7 +1444,7 @@ def local_cmd(output, output_auto, repo, gist, include_json, open_browser, limit
14431444
inject_gist_preview_js(output)
14441445
click.echo("Creating GitHub gist...")
14451446
gist_id, gist_url = create_gist(output)
1446-
preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html"
1447+
preview_url = f"https://gisthost.github.io/?{gist_id}/index.html"
14471448
click.echo(f"Gist: {gist_url}")
14481449
click.echo(f"Preview: {preview_url}")
14491450

@@ -1512,7 +1513,7 @@ def fetch_url_to_tempfile(url):
15121513
@click.option(
15131514
"--gist",
15141515
is_flag=True,
1515-
help="Upload to GitHub Gist and output a gistpreview.github.io URL.",
1516+
help="Upload to GitHub Gist and output a gisthost.github.io URL.",
15161517
)
15171518
@click.option(
15181519
"--json",
@@ -1574,7 +1575,7 @@ def json_cmd(json_file, output, output_auto, repo, gist, include_json, open_brow
15741575
inject_gist_preview_js(output)
15751576
click.echo("Creating GitHub gist...")
15761577
gist_id, gist_url = create_gist(output)
1577-
preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html"
1578+
preview_url = f"https://gisthost.github.io/?{gist_id}/index.html"
15781579
click.echo(f"Gist: {gist_url}")
15791580
click.echo(f"Preview: {preview_url}")
15801581

@@ -1823,7 +1824,7 @@ def generate_html_from_session_data(session_data, output_dir, github_repo=None):
18231824
@click.option(
18241825
"--gist",
18251826
is_flag=True,
1826-
help="Upload to GitHub Gist and output a gistpreview.github.io URL.",
1827+
help="Upload to GitHub Gist and output a gisthost.github.io URL.",
18271828
)
18281829
@click.option(
18291830
"--json",
@@ -1937,7 +1938,7 @@ def web_cmd(
19371938
inject_gist_preview_js(output)
19381939
click.echo("Creating GitHub gist...")
19391940
gist_id, gist_url = create_gist(output)
1940-
preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html"
1941+
preview_url = f"https://gisthost.github.io/?{gist_id}/index.html"
19411942
click.echo(f"Gist: {gist_url}")
19421943
click.echo(f"Preview: {preview_url}")
19431944

src/claude_code_transcripts/templates/search.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
// Show search box (progressive enhancement)
1919
searchBox.style.display = 'flex';
2020

21-
// Gist preview support - detect if we're on gistpreview.github.io
22-
var isGistPreview = window.location.hostname === 'gistpreview.github.io';
21+
// Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io
22+
var hostname = window.location.hostname;
23+
var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io';
2324
var gistId = null;
2425
var gistOwner = null;
2526
var gistInfoLoaded = false;

tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ <h1>Claude Code transcript</h1>
221221
// Show search box (progressive enhancement)
222222
searchBox.style.display = 'flex';
223223

224-
// Gist preview support - detect if we're on gistpreview.github.io
225-
var isGistPreview = window.location.hostname === 'gistpreview.github.io';
224+
// Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io
225+
var hostname = window.location.hostname;
226+
var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io';
226227
var gistId = null;
227228
var gistOwner = null;
228229
var gistInfoLoaded = false;

tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ <h1>Claude Code transcript</h1>
212212
// Show search box (progressive enhancement)
213213
searchBox.style.display = 'flex';
214214

215-
// Gist preview support - detect if we're on gistpreview.github.io
216-
var isGistPreview = window.location.hostname === 'gistpreview.github.io';
215+
// Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io
216+
var hostname = window.location.hostname;
217+
var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io';
217218
var gistId = null;
218219
var gistOwner = null;
219220
var gistInfoLoaded = false;

tests/test_generate_html.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def mock_run(*args, **kwargs):
596596
assert result.exit_code == 0
597597
assert "Creating GitHub gist" in result.output
598598
assert "gist.github.com" in result.output
599-
assert "gistpreview.github.io" in result.output
599+
assert "gisthost.github.io" in result.output
600600

601601
def test_session_gist_with_output_dir(self, monkeypatch, output_dir):
602602
"""Test that session --gist with -o uses specified directory."""
@@ -627,9 +627,9 @@ def mock_run(*args, **kwargs):
627627

628628
assert result.exit_code == 0
629629
assert (output_dir / "index.html").exists()
630-
# Verify JS was injected
630+
# Verify JS was injected (checks for both domains for backwards compatibility)
631631
index_content = (output_dir / "index.html").read_text(encoding="utf-8")
632-
assert "gistpreview.github.io" in index_content
632+
assert "gisthost.github.io" in index_content
633633

634634

635635
class TestContinuationLongTexts:
@@ -874,7 +874,7 @@ def mock_run(*args, **kwargs):
874874
assert result.exit_code == 0
875875
assert "Creating GitHub gist" in result.output
876876
assert "gist.github.com" in result.output
877-
assert "gistpreview.github.io" in result.output
877+
assert "gisthost.github.io" in result.output
878878

879879

880880
class TestVersionOption:

0 commit comments

Comments
 (0)