Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
21 changes: 11 additions & 10 deletions src/claude_code_transcripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}")

Expand Down
5 changes: 3 additions & 2 deletions src/claude_code_transcripts/templates/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ <h1>Claude Code transcript</h1>
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ <h1>Claude Code transcript</h1>
// 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;
Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down