|
7 | 7 |
|
8 | 8 | # --- Configuration for GitHub Pages --- |
9 | 9 | # Sets the base URL. CRITICAL for links/CSS/JS on GitHub Pages. |
10 | | -# Must match your repository name structure. |
| 10 | +# MUST match your repository name path. |
11 | 11 | print("Setting FREEZER_BASE_URL to '/'") |
12 | 12 | app.config['FREEZER_BASE_URL'] = '/' |
13 | 13 |
|
|
16 | 16 | # Keep .nojekyll file if generated by GitHub Actions |
17 | 17 | app.config['FREEZER_REMOVE_EXTRA_FILES'] = False |
18 | 18 |
|
| 19 | +# *** ADD THIS LINE TO FIX THE REDIRECT ISSUE *** |
| 20 | +app.config['FREEZER_FOLLOW_REDIRECTS'] = True # Tell Frozen-Flask to follow 3xx redirects |
| 21 | + |
19 | 22 | # --- Handling Dynamic URLs (IMPORTANT LIMITATION) --- |
20 | 23 | # Static site generation CANNOT dynamically create pages for every possible |
21 | 24 | # block, transaction, or address. We MUST provide examples/placeholders |
22 | 25 | # for Frozen-Flask to generate the *structure* of these pages. |
23 | | -# The actual *data* on these generated pages will only reflect |
24 | | -# what Flask renders for these specific placeholder values during the build. |
25 | | -# Features requiring real-time data or searching arbitrary hashes won't work fully. |
26 | | - |
27 | 26 | freezer = Freezer(app) |
28 | 27 |
|
29 | 28 | @freezer.register_generator |
30 | 29 | def transaction_urls(): |
31 | 30 | print("Generating static structure for /tx/<hash> using placeholder.") |
32 | | - # Provide one placeholder hash to generate the template structure |
33 | 31 | yield {'tx_hash': 'placeholder_tx_hash'} |
34 | 32 |
|
35 | 33 | @freezer.register_generator |
36 | 34 | def block_urls(): |
37 | 35 | print("Generating static structure for /block/<hash> using placeholder.") |
38 | | - # Provide one placeholder hash/number |
39 | 36 | yield {'block_hash': 'placeholder_block_hash_or_number'} |
40 | 37 |
|
41 | 38 | @freezer.register_generator |
42 | 39 | def address_urls(): |
43 | 40 | print("Generating static structure for /address/<addr> using placeholder.") |
44 | | - # Provide one placeholder address |
45 | 41 | yield {'address': 'placeholder_address'} |
46 | 42 |
|
47 | | -# You might have other dynamic routes - add generators for them too! |
48 | | - |
49 | 43 | # Main execution block for freezing |
50 | 44 | if __name__ == '__main__': |
51 | 45 | print(f"Starting static site generation for pyExplorer...") |
52 | 46 | print(f"Base URL: {app.config.get('FREEZER_BASE_URL', 'Not Set')}") |
53 | 47 | print(f"Output directory: {app.config.get('FREEZER_DESTINATION', 'build')}") |
| 48 | + print(f"Follow Redirects: {app.config.get('FREEZER_FOLLOW_REDIRECTS', False)}") |
54 | 49 |
|
55 | 50 | try: |
56 | | - # This crawls your Flask app (using defined routes and generators) |
57 | | - # and saves the output as static files. |
58 | 51 | freezer.freeze() |
59 | 52 | print(f"Static site generated successfully in '{app.config['FREEZER_DESTINATION']}'.") |
60 | 53 | print("NOTE: Only placeholder pages were generated for dynamic routes (/tx, /block, /address).") |
61 | | - print("Full dynamic explorer functionality requires a live backend or client-side fetching.") |
62 | 54 | except Exception as e: |
63 | 55 | print(f"\nERROR during freezing process: {e}\n", file=sys.stderr) |
64 | 56 | if isinstance(e, ValueError) and 'URL generator' in str(e): |
|
0 commit comments