diff --git a/README.md b/README.md index 46effea..01ca774 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,11 @@ claude-code-transcripts json session.json --gist This will output something like: ``` Gist: https://gist.github.com/username/abc123def456 -Preview: https://gistpreview.github.io/?abc123def456/index.html +Preview: https://gisthost.github.io/?abc123def456/index.html Files: /var/folders/.../session-id ``` -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. +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. Combine with `-o` to keep a local copy: diff --git a/src/claude_code_transcripts/__init__.py b/src/claude_code_transcripts/__init__.py index 8729fad..33c322d 100644 --- a/src/claude_code_transcripts/__init__.py +++ b/src/claude_code_transcripts/__init__.py @@ -1047,11 +1047,12 @@ def render_message(log_type, message_json, timestamp): }); """ -# JavaScript to fix relative URLs when served via gistpreview.github.io +# JavaScript to fix relative URLs when served via gisthost.github.io or gistpreview.github.io GIST_PREVIEW_JS = r""" (function() { - if (window.location.hostname !== 'gistpreview.github.io') return; - // URL format: https://gistpreview.github.io/?GIST_ID/filename.html + var hostname = window.location.hostname; + if (hostname !== 'gisthost.github.io' && hostname !== 'gistpreview.github.io') return; + // URL format: https://gisthost.github.io/?GIST_ID/filename.html var match = window.location.search.match(/^\?([^/]+)/); if (!match) return; var gistId = match[1]; @@ -1067,7 +1068,7 @@ def render_message(log_type, message_json, timestamp): }); // Handle fragment navigation after dynamic content loads - // gistpreview.github.io loads content dynamically, so the browser's + // gisthost.github.io/gistpreview.github.io loads content dynamically, so the browser's // native fragment navigation fails because the element doesn't exist yet function scrollToFragment() { var hash = window.location.hash; @@ -1355,7 +1356,7 @@ def cli(): @click.option( "--gist", is_flag=True, - help="Upload to GitHub Gist and output a gistpreview.github.io URL.", + help="Upload to GitHub Gist and output a gisthost.github.io URL.", ) @click.option( "--json", @@ -1443,7 +1444,7 @@ def local_cmd(output, output_auto, repo, gist, include_json, open_browser, limit inject_gist_preview_js(output) click.echo("Creating GitHub gist...") gist_id, gist_url = create_gist(output) - preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html" + preview_url = f"https://gisthost.github.io/?{gist_id}/index.html" click.echo(f"Gist: {gist_url}") click.echo(f"Preview: {preview_url}") @@ -1512,7 +1513,7 @@ def fetch_url_to_tempfile(url): @click.option( "--gist", is_flag=True, - help="Upload to GitHub Gist and output a gistpreview.github.io URL.", + help="Upload to GitHub Gist and output a gisthost.github.io URL.", ) @click.option( "--json", @@ -1574,7 +1575,7 @@ def json_cmd(json_file, output, output_auto, repo, gist, include_json, open_brow inject_gist_preview_js(output) click.echo("Creating GitHub gist...") gist_id, gist_url = create_gist(output) - preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html" + preview_url = f"https://gisthost.github.io/?{gist_id}/index.html" click.echo(f"Gist: {gist_url}") click.echo(f"Preview: {preview_url}") @@ -1823,7 +1824,7 @@ def generate_html_from_session_data(session_data, output_dir, github_repo=None): @click.option( "--gist", is_flag=True, - help="Upload to GitHub Gist and output a gistpreview.github.io URL.", + help="Upload to GitHub Gist and output a gisthost.github.io URL.", ) @click.option( "--json", @@ -1937,7 +1938,7 @@ def web_cmd( inject_gist_preview_js(output) click.echo("Creating GitHub gist...") gist_id, gist_url = create_gist(output) - preview_url = f"https://gistpreview.github.io/?{gist_id}/index.html" + preview_url = f"https://gisthost.github.io/?{gist_id}/index.html" click.echo(f"Gist: {gist_url}") click.echo(f"Preview: {preview_url}") diff --git a/src/claude_code_transcripts/templates/search.js b/src/claude_code_transcripts/templates/search.js index 48a6e1d..6bc337c 100644 --- a/src/claude_code_transcripts/templates/search.js +++ b/src/claude_code_transcripts/templates/search.js @@ -18,8 +18,9 @@ // Show search box (progressive enhancement) searchBox.style.display = 'flex'; - // Gist preview support - detect if we're on gistpreview.github.io - var isGistPreview = window.location.hostname === 'gistpreview.github.io'; + // Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io + var hostname = window.location.hostname; + var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io'; var gistId = null; var gistOwner = null; var gistInfoLoaded = false; diff --git a/tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html b/tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html index c2b6116..693c48f 100644 --- a/tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html +++ b/tests/__snapshots__/test_generate_html/TestGenerateHtml.test_generates_index_html.html @@ -221,8 +221,9 @@

Claude Code transcript

// Show search box (progressive enhancement) searchBox.style.display = 'flex'; - // Gist preview support - detect if we're on gistpreview.github.io - var isGistPreview = window.location.hostname === 'gistpreview.github.io'; + // Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io + var hostname = window.location.hostname; + var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io'; var gistId = null; var gistOwner = null; var gistInfoLoaded = false; diff --git a/tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html b/tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html index 318283c..e83424a 100644 --- a/tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html +++ b/tests/__snapshots__/test_generate_html/TestParseSessionFile.test_jsonl_generates_html.html @@ -212,8 +212,9 @@

Claude Code transcript

// Show search box (progressive enhancement) searchBox.style.display = 'flex'; - // Gist preview support - detect if we're on gistpreview.github.io - var isGistPreview = window.location.hostname === 'gistpreview.github.io'; + // Gist preview support - detect if we're on gisthost.github.io or gistpreview.github.io + var hostname = window.location.hostname; + var isGistPreview = hostname === 'gisthost.github.io' || hostname === 'gistpreview.github.io'; var gistId = null; var gistOwner = null; var gistInfoLoaded = false; diff --git a/tests/test_generate_html.py b/tests/test_generate_html.py index b79542b..2fa6e03 100644 --- a/tests/test_generate_html.py +++ b/tests/test_generate_html.py @@ -596,7 +596,7 @@ def mock_run(*args, **kwargs): assert result.exit_code == 0 assert "Creating GitHub gist" in result.output assert "gist.github.com" in result.output - assert "gistpreview.github.io" in result.output + assert "gisthost.github.io" in result.output def test_session_gist_with_output_dir(self, monkeypatch, output_dir): """Test that session --gist with -o uses specified directory.""" @@ -627,9 +627,9 @@ def mock_run(*args, **kwargs): assert result.exit_code == 0 assert (output_dir / "index.html").exists() - # Verify JS was injected + # Verify JS was injected (checks for both domains for backwards compatibility) index_content = (output_dir / "index.html").read_text(encoding="utf-8") - assert "gistpreview.github.io" in index_content + assert "gisthost.github.io" in index_content class TestContinuationLongTexts: @@ -874,7 +874,7 @@ def mock_run(*args, **kwargs): assert result.exit_code == 0 assert "Creating GitHub gist" in result.output assert "gist.github.com" in result.output - assert "gistpreview.github.io" in result.output + assert "gisthost.github.io" in result.output class TestVersionOption: