GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Load the live lion counter on the GitHub profile · mxsm/mxsm@63501ac

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • profile-3d.yml
  • README.md
  • scripts
    • view_counter.py
  • tests
    • test_views.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/profile-3d.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/profile-3d.yml
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ jobs:
3535
python3 -B scripts/update_profile.py contributions
3636
git add -- resource/generated/contributions.{json,svg}
3737
38-
- name: Refresh the Foshan lion view counter
39-
if: ${{ !cancelled() && steps.checkout.outcome == 'success' }}
40-
run: |
41-
python3 -B scripts/update_profile.py profile-views
42-
git add -- resource/generated/profile-views.{json,svg}
43-
4438
- name: Publish successfully generated cards
4539
if: ${{ !cancelled() && steps.checkout.outcome == 'success' && github.ref_type == 'branch' }}
4640
run: |
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+1-2Lines changed: 1 addition & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ I’m a Java and Rust developer living in Foshan and working in Guangzhou. I gra
5050
</a>
5151
-->
5252

53-
<!-- The original counter still records image requests. The lion card displays its daily total. -->
5453
<p align="center">
5554
<a href="./resource/generated/languages.svg"><img src="./resource/generated/languages.svg" alt="Most used languages by share of code, updated monthly" width="49%" /></a>
56-
<a href="./resource/generated/profile-views.svg"><img src="./resource/generated/profile-views.svg" alt="Profile views since July 30, 2023, displayed by Foshan lions on drums and updated daily" width="49%" /></a><img src="https://count.getloli.com/get/@:mxsm?theme=normal-1" alt="" width="1" height="1" />
55+
<a href="https://github-readme-stats-mxsm.vercel.app/api/profile-views"><img src="https://github-readme-stats-mxsm.vercel.app/api/profile-views" alt="Live profile views since July 30, 2023, displayed by Foshan lions on drums" width="49%" /></a>
5756
</p>
5857

5958
[![Weekly contributions on the Pearl River skyline and seven days of contributions on Foshan lion dance poles](./resource/generated/contributions.svg)](./resource/generated/contributions.svg)
Collapse file

‎scripts/view_counter.py‎

Copy file name to clipboardExpand all lines: scripts/view_counter.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def read_counter_image(url):
4343

4444

4545
def displayed_total(owner):
46+
if owner == "mxsm":
47+
return read_counter_image(original_counter_image())
4648
page = f"https://github.com/{quote(owner, safe='')}"
4749
return read_counter_image(counter_image_url(owner, page))
4850

@@ -76,7 +78,7 @@ def fetch_views(owner, now):
7678
count = series_total(owner)
7779
source = "counter-api"
7880
except (URLError, TimeoutError) as error:
79-
print(f"Counter API unavailable ({error}). Reading the counter image from the GitHub profile.")
81+
print(f"Counter API unavailable ({error}). Reading the published counter image.")
8082
count = displayed_total(owner)
8183
source = "profile-counter-image"
8284
return {"owner": owner, "updated_at": now.isoformat(), "count": count, "source": source}
Collapse file

‎tests/test_views.py‎

Copy file name to clipboardExpand all lines: tests/test_views.py
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ProfileViewsTest(unittest.TestCase):
2121
legacy = "https://count.getloli.com/get/@:mxsm?theme=gelbooru-h"
2222
camo = "https://camo.githubusercontent.com/" + "a" * 64 + "/" + legacy.encode().hex()
2323

24+
def setUp(self):
25+
view_counter.original_counter_image.cache_clear()
26+
self.addCleanup(view_counter.original_counter_image.cache_clear)
27+
2428
def profile_html(self):
2529
return io.BytesIO(f'''<article class="markdown-body">
2630
<img src="https://github.com/mxsm/mxsm/raw/main/resource/generated/profile-views.svg" />
@@ -33,14 +37,22 @@ def counter_svg(self, refs):
3337
return io.BytesIO(f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3438
<defs><image id="0" /><image id="3" /><image id="4" /></defs><g>{uses}</g></svg>'''.encode())
3539

36-
def test_blocked_series_reads_profile_counter_digits_in_order(self):
40+
def test_blocked_series_reads_counter_from_pinned_readme_in_digit_order(self):
3741
forbidden = HTTPError(self.legacy, 403, "Forbidden", {}, io.BytesIO())
3842
self.addCleanup(forbidden.close)
3943
svg = self.counter_svg(["#0", "#0", "#3", "#0", "#0", "#3", "#4"])
4044
with patch.object(view_counter, "urlopen", side_effect=[forbidden, self.profile_html(), svg]) as fetch:
4145
snapshot = view_counter.fetch_views("mxsm", self.now)
4246
self.assertEqual((snapshot["count"], snapshot["source"]), (30034, "profile-counter-image"))
43-
self.assertEqual([call.args[0] for call in fetch.call_args_list[1:]], ["https://github.com/mxsm", self.camo])
47+
readme = fetch.call_args_list[1].args[0]
48+
self.assertRegex(readme.full_url, r"^https://api\.github\.com/repos/mxsm/mxsm/readme\?ref=[a-f0-9]{40}$")
49+
self.assertEqual(readme.get_header("Accept"), "application/vnd.github.html+json")
50+
self.assertEqual(fetch.call_args_list[2].args[0], self.camo)
51+
52+
def test_other_owner_reads_counter_from_their_current_profile(self):
53+
with patch.object(view_counter, "urlopen", side_effect=[self.profile_html(), self.counter_svg(["#4"])]) as fetch:
54+
self.assertEqual(view_counter.displayed_total("other"), 4)
55+
self.assertEqual([call.args[0] for call in fetch.call_args_list], ["https://github.com/other", self.camo + "-other"])
4456

4557
def test_bad_displayed_digit_preserves_published_counter(self):
4658
with TemporaryDirectory() as folder:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.