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
16 changes: 8 additions & 8 deletions profile/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!-- Generated by tools/snodec_sync profile from catalog.yml and profile/template.md; edit those, not this file. -->
<p>
<picture>
<source media="(max-width: 600px)" srcset="media/hero-mobile.svg">
<img src="media/hero.svg" alt="SNode.C — one event loop, a whole ecosystem: SNode.C, MQTTSuite, AISuite, CodexUI, Packages, the Book Companion and community projects." width="100%">
<source media="(max-width: 600px)" srcset="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/hero-mobile.svg">
<img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/hero.svg" alt="SNode.C — one event loop, a whole ecosystem: SNode.C, MQTTSuite, AISuite, CodexUI, Packages, the Book Companion and community projects." width="100%">
</picture>
</p>

# SNode.C

<picture>
<source media="(prefers-color-scheme: dark)" srcset="media/snodec-org-chip-dark.svg">
<img src="media/snodec-org-chip-light.svg" alt="Organization · Ecosystem" width="240" height="32">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/snodec-org-chip-dark.svg">
<img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/snodec-org-chip-light.svg" alt="Organization · Ecosystem" width="240" height="32">
</picture>

<!-- snodec:begin status -->
Expand All @@ -23,10 +23,10 @@ SNode.C builds event-driven networking in C++. At its centre is [SNode.C](https:

<!-- snodec:begin menu -->
<p>
<a href="#products" title="Products"><img src="media/menu/products.svg" alt="Products" width="160" height="28"></a>
<a href="#install" title="Install"><img src="media/menu/install.svg" alt="Install" width="160" height="28"></a>
<a href="#learn" title="Learn"><img src="media/menu/learn.svg" alt="Learn" width="160" height="28"></a>
<a href="#contributing" title="Contribute"><img src="media/menu/contribute.svg" alt="Contribute" width="160" height="28"></a>
<a href="#products" title="Products"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/products.svg" alt="Products" width="160" height="28"></a>
<a href="#install" title="Install"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/install.svg" alt="Install" width="160" height="28"></a>
<a href="#learn" title="Learn"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/learn.svg" alt="Learn" width="160" height="28"></a>
<a href="#contributing" title="Contribute"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/contribute.svg" alt="Contribute" width="160" height="28"></a>
</p>
<!-- snodec:end menu -->

Expand Down
18 changes: 9 additions & 9 deletions profile/template.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!-- Authored prose for the generated organization profile; edit this template and catalog.yml, not profile/README.md. -->
<!-- Authored prose for the generated organization profile; edit this template and catalog.yml, not profile/README.md. Use absolute public asset URLs so GitHub Mobile and the member profile share the same image location. -->
<p>
<picture>
<source media="(max-width: 600px)" srcset="media/hero-mobile.svg">
<img src="media/hero.svg" alt="SNode.C — one event loop, a whole ecosystem: SNode.C, MQTTSuite, AISuite, CodexUI, Packages, the Book Companion and community projects." width="100%">
<source media="(max-width: 600px)" srcset="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/hero-mobile.svg">
<img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/hero.svg" alt="SNode.C — one event loop, a whole ecosystem: SNode.C, MQTTSuite, AISuite, CodexUI, Packages, the Book Companion and community projects." width="100%">
</picture>
</p>

# SNode.C

<picture>
<source media="(prefers-color-scheme: dark)" srcset="media/snodec-org-chip-dark.svg">
<img src="media/snodec-org-chip-light.svg" alt="Organization · Ecosystem" width="240" height="32">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/snodec-org-chip-dark.svg">
<img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/snodec-org-chip-light.svg" alt="Organization · Ecosystem" width="240" height="32">
</picture>

<!-- snodec:begin status -->
Expand All @@ -23,10 +23,10 @@ SNode.C builds event-driven networking in C++. At its centre is [SNode.C](https:

<!-- snodec:begin menu -->
<p>
<a href="#products" title="Products"><img src="media/menu/products.svg" alt="Products" width="160" height="28"></a>
<a href="#install" title="Install"><img src="media/menu/install.svg" alt="Install" width="160" height="28"></a>
<a href="#learn" title="Learn"><img src="media/menu/learn.svg" alt="Learn" width="160" height="28"></a>
<a href="#contributing" title="Contribute"><img src="media/menu/contribute.svg" alt="Contribute" width="160" height="28"></a>
<a href="#products" title="Products"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/products.svg" alt="Products" width="160" height="28"></a>
<a href="#install" title="Install"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/install.svg" alt="Install" width="160" height="28"></a>
<a href="#learn" title="Learn"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/learn.svg" alt="Learn" width="160" height="28"></a>
<a href="#contributing" title="Contribute"><img src="https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/contribute.svg" alt="Contribute" width="160" height="28"></a>
</p>
<!-- snodec:end menu -->

Expand Down
16 changes: 16 additions & 0 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ def test_control_repository_uses_declared_navigation(self):
self.assertIn('SNode.C', (repo / 'docs/media/nav/up-snodec-light.svg').read_text())
self.assertEqual(page_headers(repo, check=True), [])

def test_absolute_profile_menu_keeps_local_generation_and_url(self):
repo = self.fixture('.github')
asset = repo / 'profile/media/menu/products.svg'
asset.parent.mkdir(parents=True)
asset.write_text(_menu_svg('Products', 274))
url = 'https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/media/menu/products.svg'
foreign = 'https://example.com/menu.svg'
profile = repo / 'profile/README.md'
profile.write_text(f'# Organization\n\n<a href="#products"><img src="{url}" width="274" height="28"></a>\n'
f'<img src="{foreign}" width="274" height="28">\n')
page_headers(repo)
self.assertIn('width="160" height="28"', asset.read_text())
self.assertIn(f'src="{url}" width="160" height="28"', profile.read_text())
self.assertIn(f'src="{foreign}" width="274" height="28"', profile.read_text())
self.assertEqual(page_headers(repo, check=True), [])

def test_plan_chains_and_label_limit(self):
validate_plan(self.plan)
invalid = copy.deepcopy(self.plan)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ def test_template_markers_are_exactly_once_and_standalone(self):
with self.assertRaisesRegex(ValueError, 'exactly one standalone'):
render_profile(self.catalog, self.metadata, template)

def test_relative_media_paths_exist(self):
paths = re.findall(r'(?:src|srcset)="(media/[^"\s]+)"', self.profile)
def test_profile_images_use_absolute_public_urls_and_owned_assets(self):
prefix = 'https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/'
paths = re.findall(r'(?:src|srcset)="([^"\s]+)"', self.profile)
self.assertTrue(paths)
for path in paths:
self.assertTrue((ROOT / 'profile' / path).is_file(), path)
self.assertTrue(path.startswith(prefix), path)
self.assertTrue((ROOT / 'profile' / path.removeprefix(prefix)).is_file(), path)

def test_metadata_is_separate_and_complete(self):
self.assertEqual(set(self.metadata), {e['name'] for e in self.catalog})
Expand Down
7 changes: 3 additions & 4 deletions tools/snodec_sync/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,9 @@ def anchor(match):
text = re.sub(r'\[!\[([^\]]*)\]\(([^)]+)\)\]\(([^)]+)\)',
lambda m: '' if _up_link(m[2], m[3], path, ancestors) else m[0], text)
for src in re.findall(r'(?:src="|!\[[^\]]*\]\()([^"\s)]+\.svg)', text):
if src.startswith(('https:', 'http:', '/')):
continue
asset = posixpath.normpath(posixpath.join(posixpath.dirname(path), src))
if '..' in PurePosixPath(asset).parts or not (checkout / asset).is_file():
asset = posixpath.normpath(posixpath.join(posixpath.dirname(path),
src.removeprefix('https://raw.githubusercontent.com/SNodeC/.github/refs/heads/main/profile/') if path == 'profile/README.md' else src))
if asset.startswith('/') or ':/' in asset or '..' in PurePosixPath(asset).parts or not (checkout / asset).is_file():
continue
svg = ET.parse(checkout / asset).getroot()
if svg.attrib.get('height') != '28' or 'nav' in PurePosixPath(asset).parts:
Expand Down