Skip to content

Commit ec547b4

Browse files
committed
Add docs for URL feature
1 parent c180787 commit ec547b4

File tree

6 files changed

+489
-1
lines changed

6 files changed

+489
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ An advent calendar for 2025, to highlight InnerSource patterns that need your he
66

77
- create content for the calendar / e.g. pick patterns from [this list](https://github.com/InnerSourceCommons/InnerSourcePatterns/issues/772) that could be improved
88
- (optional) hide days until that day is reached i.e. only once we reach December 1st, 2025 the 1st "door" in the advent calendar can be opened
9-
- (optional) create individual URLs for each day (so that we can share individual days on social media etc)
9+
- **(done)** create individual URLs for each day (so that we can share individual days on social media etc)
1010

1111
## Assessment for my use case
1212

docs/IMPLEMENTATION-NOTES.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Implementation Summary: Individual URLs for Each Day
2+
3+
## What Was Changed
4+
5+
### Modified Files
6+
1. **`js/main2.js`** - Added URL hash functionality
7+
8+
### New Files Created
9+
1. **`URL-SHARING.md`** - Documentation on how to use the new URL feature
10+
2. **`test-links.html`** - Demo page to test direct links to each day
11+
12+
## Key Features Implemented
13+
14+
### 1. URL Hash Support
15+
Each day now has a unique URL using hash fragments:
16+
- Day 1: `index.html#day-1`
17+
- Day 2: `index.html#day-2`
18+
- Day 3: `index.html#day-3`
19+
- ...and so on
20+
21+
### 2. Auto-Open on Page Load
22+
When someone visits a URL with a hash (e.g., `index.html#day-5`), the calendar automatically opens to that specific day.
23+
24+
### 3. URL Updates on Click
25+
When you click a day, the browser URL automatically updates to include the day's hash, making it easy to copy and share.
26+
27+
### 4. Browser Navigation Support
28+
The browser's back and forward buttons work correctly:
29+
- Back button returns to the calendar view
30+
- Forward button opens the day again
31+
32+
### 5. Clean Back Navigation
33+
When clicking the back arrow in the calendar, the URL hash is cleared, returning to the base URL.
34+
35+
## Technical Implementation Details
36+
37+
### Changes to `main2.js`:
38+
39+
1. **Added global variable** to store calendar instance:
40+
```javascript
41+
calendarInstance;
42+
```
43+
44+
2. **Created `checkURLHash()` function**:
45+
- Reads the URL hash on page load
46+
- Parses the day number
47+
- Automatically opens the corresponding day if valid
48+
49+
3. **Modified `init()` function**:
50+
- Calls `checkURLHash()` after layout
51+
- Adds event listener for `hashchange` events (browser navigation)
52+
53+
4. **Updated `layout()` function**:
54+
- Stores the Calendar instance in `calendarInstance` variable
55+
56+
5. **Enhanced click handler**:
57+
- Updates URL hash using `window.history.pushState()`
58+
- Format: `#day-N` where N is the 1-based day number
59+
60+
6. **Enhanced back button handler**:
61+
- Clears the URL hash when returning to calendar view
62+
- Uses `window.history.pushState()` to update URL
63+
64+
## How to Use
65+
66+
### For End Users:
67+
1. Open the calendar
68+
2. Click any active day
69+
3. The URL in your browser will update (e.g., `index.html#day-3`)
70+
4. Copy and share that URL
71+
5. Anyone who visits that URL will see that specific day automatically opened
72+
73+
### For Developers:
74+
You can create direct links in your HTML or markdown:
75+
```html
76+
<a href="index.html#day-1">Check out Day 1!</a>
77+
```
78+
79+
### For Social Media/Marketing:
80+
Share complete URLs:
81+
```
82+
https://yourdomain.com/advent-calendar/index.html#day-5
83+
```
84+
85+
## Testing
86+
87+
### Test Page
88+
Open `test-links.html` in your browser to see all direct links and test them.
89+
90+
### Manual Testing Steps:
91+
1. Open `index.html` in a browser
92+
2. Click on day 5 - URL should change to `index.html#day-5`
93+
3. Refresh the page - Day 5 should open automatically
94+
4. Click the back arrow - URL should change back to `index.html`
95+
5. Use browser back button - Should return to day 5
96+
6. Test with a direct link: `index.html#day-3`
97+
98+
## Browser Compatibility
99+
Works in all modern browsers that support:
100+
- `window.location.hash`
101+
- `window.history.pushState()`
102+
- `addEventListener('hashchange')`
103+
104+
This includes: Chrome, Firefox, Safari, Edge, and all mobile browsers.
105+
106+
## Advantages of This Approach
107+
108+
1. **No Server Configuration**: Works with static hosting (GitHub Pages, Netlify, etc.)
109+
2. **No File Duplication**: Still uses a single HTML file
110+
3. **SEO Friendly**: Hash fragments are indexed by search engines
111+
4. **Social Media Friendly**: URLs are shareable on all platforms
112+
5. **Backwards Compatible**: Works alongside existing functionality
113+
6. **Performance**: No additional HTTP requests needed
114+
115+
## Future Enhancements (Optional)
116+
117+
If you want to make this even better, you could:
118+
1. Add Open Graph meta tags that update based on the day opened
119+
2. Implement analytics tracking for which days are most popular
120+
3. Add a "Share" button that copies the current day's URL to clipboard
121+
4. Create a QR code generator for each day's URL

docs/QUICK-REFERENCE.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Quick Reference: URL Sharing
2+
3+
## 📋 Quick Links
4+
5+
### Active Days (Ready to Share)
6+
```
7+
index.html#day-1 → Welcome
8+
index.html#day-2 → Code of Conduct
9+
index.html#day-3 → Balancing Openness and Security
10+
index.html#day-4 → InnerSource Ambassadors
11+
index.html#day-5 → Live Freely
12+
index.html#day-6 → Tolerable Planet
13+
index.html#day-7 → Normal
14+
index.html#day-8 → Superhero
15+
index.html#day-9 → New Weariness
16+
index.html#day-10 → The Sinner
17+
index.html#day-11 → Intellectual Wealth
18+
index.html#day-12 → Limiting Principle
19+
index.html#day-13 → Quaintly Free
20+
index.html#day-14 → On A Level
21+
index.html#day-15 → Experiences
22+
index.html#day-16 → Entrenched
23+
index.html#day-17 → Happiness
24+
index.html#day-18 → Working Jobs
25+
index.html#day-19 → Spending Billions
26+
index.html#day-20 → Principle Of Having
27+
index.html#day-21 → Enemies
28+
index.html#day-22 → Better World
29+
index.html#day-23 → Coming soon
30+
index.html#day-24 → Coming soon
31+
index.html#day-25 → Coming soon
32+
```
33+
34+
## 🚀 How It Works
35+
36+
1. **Click a day** → URL updates automatically
37+
2. **Copy the URL** → Share it anywhere
38+
3. **Someone clicks** → That day opens automatically
39+
40+
## ✅ What Works
41+
42+
- ✅ Direct links to any day
43+
- ✅ Browser back/forward buttons
44+
- ✅ URL sharing on social media
45+
- ✅ Bookmarking specific days
46+
- ✅ Works with all browsers
47+
- ✅ No server configuration needed
48+
49+
## 📱 Social Media Tips
50+
51+
**Twitter/X:**
52+
```
53+
Check out Day 5 of our #InnerSource Patterns Advent Calendar! 🎄
54+
https://yourdomain.com/index.html#day-5
55+
```
56+
57+
**LinkedIn:**
58+
```
59+
Discover InnerSource patterns this December!
60+
Today's focus: Day 3 - Balancing Openness and Security
61+
https://yourdomain.com/index.html#day-3
62+
```
63+
64+
**Email:**
65+
```
66+
Subject: Day 7 of InnerSource Patterns Advent Calendar
67+
68+
Click here to see today's pattern:
69+
https://yourdomain.com/index.html#day-7
70+
```
71+
72+
## 🔗 Creating Links in HTML
73+
74+
```html
75+
<!-- Simple link -->
76+
<a href="index.html#day-1">Day 1</a>
77+
78+
<!-- With custom text -->
79+
<a href="index.html#day-5">Read today's pattern</a>
80+
81+
<!-- In a button -->
82+
<button onclick="window.location.href='index.html#day-10'">
83+
Go to Day 10
84+
</button>
85+
```
86+
87+
## 🧪 Testing
88+
89+
1. Open `test-links.html` to see all links
90+
2. Click any link to test
91+
3. Verify URL changes
92+
4. Test browser back button
93+
5. Refresh and verify day stays open
94+
95+
## 💡 Pro Tips
96+
97+
- Share a different day each day of December
98+
- Use short URLs (bit.ly, etc.) for social media
99+
- Include the day number in your social posts
100+
- Create a "Day of the Week" schedule

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
These files were added when creating the individual URLs for each day.
2+
3+
You might have to move `test-links.html` back to the root of this repo for it to work.

docs/URL-SHARING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# URL Sharing Feature
2+
3+
## Overview
4+
Each day in the advent calendar now has its own unique URL that can be shared directly.
5+
6+
## URL Format
7+
To link to a specific day, use the following URL format:
8+
```
9+
index.html#day-N
10+
```
11+
12+
Where `N` is the day number (1-25).
13+
14+
## Examples
15+
- Day 1 (Welcome): `index.html#day-1`
16+
- Day 2 (Code of Conduct): `index.html#day-2`
17+
- Day 3 (Balancing Openness and Security): `index.html#day-3`
18+
- Day 4 (InnerSource Ambassadors): `index.html#day-4`
19+
- ...and so on
20+
21+
## Features
22+
1. **Direct Links**: Share a specific day by copying the URL from your browser
23+
2. **Auto-Open**: When someone clicks a day-specific link, that day automatically opens
24+
3. **Browser Navigation**: The browser's back/forward buttons work as expected
25+
4. **Shareable**: Perfect for social media, emails, or documentation
26+
27+
## Usage
28+
29+
### For Users
30+
1. Click on any active day in the calendar
31+
2. The URL will automatically update to include `#day-N`
32+
3. Copy and share that URL with others
33+
4. When they visit the URL, that specific day will open automatically
34+
35+
### For Developers/Marketers
36+
Create direct links to specific days:
37+
```html
38+
<a href="index.html#day-1">Check out Day 1!</a>
39+
<a href="index.html#day-5">See Day 5</a>
40+
```
41+
42+
## Technical Details
43+
- Uses URL hash fragments (`#day-N`)
44+
- Works with static hosting (GitHub Pages, etc.)
45+
- No server-side configuration required
46+
- Maintains single-file architecture
47+
- Supports browser history (back/forward buttons)

0 commit comments

Comments
 (0)