diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b8eab90 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build README + +on: + push: + workflow_dispatch: + schedule: + - cron: '32 * * * *' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - uses: actions/cache@v2 + name: Configure pip caching + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install Python dependencies + run: | + python -m pip install -r requirements.txt + - name: Update README + env: + SIMONW_TOKEN: ${{ secrets.SIMONW_TOKEN }} + run: |- + python build_readme.py + cat README.md + - name: Commit and push if changed + run: |- + git diff + git config --global user.email "readme-bot@example.com" + git config --global user.name "README-bot" + git add -A + git commit -m "Updated content" || exit 0 + git push diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 9bc266c..e9e53e9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Repos below are my WordPress plugins hosted here at GitHub. Easy to install, and -

🚀 WP Loupe ⭐ 80

+

🚀 WP Loupe ⭐ 81

WP Loupe is a powerful search enhancement plugin for WordPress that delivers fast, accurate, and typo-tolerant search results. WP Loupe exposes a developer-friendly API so you can build your own search UI.


@@ -64,7 +64,7 @@ Repos below are my WordPress plugins hosted here at GitHub. Easy to install, and
-
Multisite Exporter ⭐ 5
+
Multisite Exporter ⭐ 6
Multisite Exporter is a WordPress plugin that allows you to export content from all subsites in a WordPress multisite installation. The plugin generates WordPress XML (WXR) files by running the WordPress exporter on each subsite in the background using the Action Scheduler library, making it efficient even for large multisite networks.
@@ -106,7 +106,7 @@ Repos below are my WordPress plugins hosted here at GitHub. Easy to install, and
-
Virtual Media Folders AI Organizer
+
Virtual Media Folders AI Organizer ⭐ 1
AI-powered media organization add-on for the Virtual Media Folders plugin. Uses vision-capable AI models to analyze actual image content and automatically organize your media library into virtual folders.
diff --git a/build_readme.py b/build_readme.py index 6a9adda..db351d3 100644 --- a/build_readme.py +++ b/build_readme.py @@ -1,7 +1,5 @@ from python_graphql_client import GraphqlClient import feedparser -import tweepy -import time import httpx import json import pathlib @@ -12,90 +10,161 @@ client = GraphqlClient(endpoint="https://api.github.com/graphql") -TOKEN = os.environ.get("SODERLIND_TOKEN", "") +TOKEN = os.environ.get("SIMONW_TOKEN", "") def replace_chunk(content, marker, chunk, inline=False): - r = re.compile( - r".*".format(marker, marker), - re.DOTALL, - ) - if not inline: - chunk = "\n{}\n".format(chunk) - chunk = "{}".format( - marker, chunk, marker) - return r.sub(chunk, content) + r = re.compile( + r".*".format(marker, marker), + re.DOTALL, + ) + if not inline: + chunk = "\n{}\n".format(chunk) + chunk = "{}".format(marker, chunk, marker) + return r.sub(chunk, content) def make_query(after_cursor=None): - return """ + return """ query { viewer { - repositories(first: 100, orderBy: {field:PUSHED_AT, direction:DESC}, privacy: PUBLIC, isFork: false,after:AFTER) { - pageInfo {hasNextPage, endCursor} - nodes { - name - description - pushedAt - url - forkCount - } - } + repositories(first: 100, privacy: PUBLIC, after:AFTER) { + pageInfo { + hasNextPage + endCursor + } + nodes { + name + description + url + releases(last:1) { + totalCount + nodes { + name + publishedAt + url + } + } + } + } } } """.replace( - "AFTER", '"{}"'.format(after_cursor) if after_cursor else "null" - ) - - -def fetch_plugins(oauth_token): - plugins = [] - has_next_page = True - after_cursor = None - - while has_next_page: - data = client.execute( - query=make_query(after_cursor), - headers={"Authorization": "Bearer {}".format(oauth_token)}, - ) - print() - print(json.dumps(data, indent=4)) - print() - i = 0 - # for i, repo in enumerate(data["data"]["viewer"]["repositories"]["nodes"]): - for repo in data["data"]["viewer"]["repositories"]["nodes"]: - plugin_url = repo["url"] + "/blob/master/" + repo["name"] + ".php" - if len(str(repo["description"])) > 4 and httpx.get(plugin_url).status_code == 200: - plugins.append( - { - "repo": repo["name"], - "url": repo["url"], - "font_format": "**" if i % 2 == 0 else "*", - "description": repo["description"].strip(), - "pushed_at": repo["pushedAt"], - "fork_count": repo["forkCount"], - } - ) - i = i+1 - has_next_page = data["data"]["viewer"]["repositories"]["pageInfo"][ - "hasNextPage" - ] - after_cursor = data["data"]["viewer"]["repositories"]["pageInfo"]["endCursor"] - return plugins + "AFTER", '"{}"'.format(after_cursor) if after_cursor else "null" + ) + + +def fetch_releases(oauth_token): + repos = [] + releases = [] + repo_names = set() + has_next_page = True + after_cursor = None + + while has_next_page: + data = client.execute( + query=make_query(after_cursor), + headers={"Authorization": "Bearer {}".format(oauth_token)}, + ) + print() + print(json.dumps(data, indent=4)) + print() + for repo in data["data"]["viewer"]["repositories"]["nodes"]: + if repo["releases"]["totalCount"] and repo["name"] not in repo_names: + repos.append(repo) + repo_names.add(repo["name"]) + releases.append( + { + "repo": repo["name"], + "repo_url": repo["url"], + "description": repo["description"], + "release": repo["releases"]["nodes"][0]["name"] + .replace(repo["name"], "") + .strip(), + "published_at": repo["releases"]["nodes"][0]["publishedAt"], + "published_day": repo["releases"]["nodes"][0][ + "publishedAt" + ].split("T")[0], + "url": repo["releases"]["nodes"][0]["url"], + } + ) + has_next_page = data["data"]["viewer"]["repositories"]["pageInfo"][ + "hasNextPage" + ] + after_cursor = data["data"]["viewer"]["repositories"]["pageInfo"]["endCursor"] + return releases + + +def fetch_tils(): + sql = "select title, url, created_utc from til order by created_utc desc limit 5" + return httpx.get( + "https://til.simonwillison.net/til.json", + params={"sql": sql, "_shape": "array",}, + ).json() + + +def fetch_blog_entries(): + entries = feedparser.parse("https://simonwillison.net/atom/entries/")["entries"] + return [ + { + "title": entry["title"], + "url": entry["link"].split("#")[0], + "published": entry["published"].split("T")[0], + } + for entry in entries + ] if __name__ == "__main__": - readme = root / "README.md" - plugins = fetch_plugins(TOKEN) - plugins.sort(key=lambda r: r["pushed_at"], reverse=True) - md = "\n".join( - [ - "[{font_format}{description}{font_format}]({url})    ".format( - **plugin) - for plugin in plugins[:20] - ] - ) - readme_contents = readme.open().read() - rewritten = replace_chunk(readme_contents, "plugins", md) - - readme.open("w").write(rewritten) + readme = root / "README.md" + project_releases = root / "releases.md" + releases = fetch_releases(TOKEN) + releases.sort(key=lambda r: r["published_at"], reverse=True) + md = "\n".join( + [ + "* [{repo} {release}]({url}) - {published_day}".format(**release) + for release in releases[:8] + ] + ) + readme_contents = readme.open().read() + rewritten = replace_chunk(readme_contents, "recent_releases", md) + + # Write out full project-releases.md file + project_releases_md = "\n".join( + [ + ( + "* **[{repo}]({repo_url})**: [{release}]({url}) - {published_day}\n" + "
{description}" + ).format(**release) + for release in releases + ] + ) + project_releases_content = project_releases.open().read() + project_releases_content = replace_chunk( + project_releases_content, "recent_releases", project_releases_md + ) + project_releases_content = replace_chunk( + project_releases_content, "release_count", str(len(releases)), inline=True + ) + project_releases.open("w").write(project_releases_content) + + tils = fetch_tils() + tils_md = "\n".join( + [ + "* [{title}]({url}) - {created_at}".format( + title=til["title"], + url=til["url"], + created_at=til["created_utc"].split("T")[0], + ) + for til in tils + ] + ) + rewritten = replace_chunk(rewritten, "tils", tils_md) + + entries = fetch_blog_entries()[:5] + entries_md = "\n".join( + ["* [{title}]({url}) - {published}".format(**entry) for entry in entries] + ) + rewritten = replace_chunk(rewritten, "blog", entries_md) + + readme.open("w").write(rewritten) diff --git a/releases.md b/releases.md index 8b13789..1191769 100644 --- a/releases.md +++ b/releases.md @@ -1 +1,154 @@ +# Released projects +All 74 of my released projects, ordered by the date of their most recent release. + + +* **[sqlite-utils](https://github.com/simonw/sqlite-utils)**: [2.14.1](https://github.com/simonw/sqlite-utils/releases/tag/2.14.1) - 2020-08-06 +
Python CLI utility and library for manipulating SQLite databases +* **[datasette-graphql](https://github.com/simonw/datasette-graphql)**: [0.5](https://github.com/simonw/datasette-graphql/releases/tag/0.5) - 2020-08-06 +
A GraphQL endpoint for Datasette +* **[datasette-insert-unsafe](https://github.com/simonw/datasette-insert-unsafe)**: [0.1](https://github.com/simonw/datasette-insert-unsafe/releases/tag/0.1) - 2020-07-31 +
Unsafe permissions for datasette-insert - allows all actions without authentication +* **[datasette-insert](https://github.com/simonw/datasette-insert)**: [0.6](https://github.com/simonw/datasette-insert/releases/tag/0.6) - 2020-07-31 +
Datasette plugin for inserting and updating data +* **[datasette-publish-vercel](https://github.com/simonw/datasette-publish-vercel)**: [0.7](https://github.com/simonw/datasette-publish-vercel/releases/tag/0.7) - 2020-07-31 +
Datasette plugin for publishing data using Vercel +* **[datasette-media](https://github.com/simonw/datasette-media)**: [0.5](https://github.com/simonw/datasette-media/releases/tag/0.5) - 2020-07-29 +
Datasette plugin for serving files from disk based on a SQL query +* **[db-to-sqlite](https://github.com/simonw/db-to-sqlite)**: [1.3](https://github.com/simonw/db-to-sqlite/releases/tag/1.3) - 2020-07-27 +
CLI tool for exporting tables or queries from any SQL database to a SQLite file +* **[datasette-render-images](https://github.com/simonw/datasette-render-images)**: [0.3.1](https://github.com/simonw/datasette-render-images/releases/tag/0.3.1) - 2020-07-27 +
Datasette plugin that renders binary blob images using data-uris +* **[datasette-auth-passwords](https://github.com/simonw/datasette-auth-passwords)**: [0.3.1](https://github.com/simonw/datasette-auth-passwords/releases/tag/0.3.1) - 2020-07-26 +
Datasette plugin for authentication using passwords +* **[twitter-to-sqlite](https://github.com/dogsheep/twitter-to-sqlite)**: [0.21.3](https://github.com/dogsheep/twitter-to-sqlite/releases/tag/0.21.3) - 2020-07-23 +
Save data from Twitter to a SQLite database +* **[datasette-clone](https://github.com/simonw/datasette-clone)**: [0.5](https://github.com/simonw/datasette-clone/releases/tag/0.5) - 2020-07-22 +
Create a local copy of database files from a Datasette instance +* **[datasette-copyable](https://github.com/simonw/datasette-copyable)**: [0.2](https://github.com/simonw/datasette-copyable/releases/tag/0.2) - 2020-07-21 +
Datasette plugin for outputting tables in formats suitable for copy and paste +* **[datasette-auth-tokens](https://github.com/simonw/datasette-auth-tokens)**: [0.2.2](https://github.com/simonw/datasette-auth-tokens/releases/tag/0.2.2) - 2020-07-20 +
Datasette plugin for authenticating access using API tokens +* **[github-to-sqlite](https://github.com/dogsheep/github-to-sqlite)**: [2.4](https://github.com/dogsheep/github-to-sqlite/releases/tag/2.4) - 2020-07-18 +
Save data from GitHub to a SQLite database +* **[datasette-plugin-demos](https://github.com/simonw/datasette-plugin-demos)**: [0.4](https://github.com/simonw/datasette-plugin-demos/releases/tag/0.4) - 2020-07-14 +
Some examples plugins for Datasette +* **[datasette-publish-fly](https://github.com/simonw/datasette-publish-fly)**: [1.0](https://github.com/simonw/datasette-publish-fly/releases/tag/1.0) - 2020-07-11 +
Datasette plugin for publishing data using Fly +* **[datasette-edit-tables](https://github.com/simonw/datasette-edit-tables)**: [0.2a](https://github.com/simonw/datasette-edit-tables/releases/tag/0.2a) - 2020-07-06 +
Datasette plugin for renaming and deleting tables and columns and changing column types +* **[datasette-configure-fts](https://github.com/simonw/datasette-configure-fts)**: [1.0](https://github.com/simonw/datasette-configure-fts/releases/tag/1.0) - 2020-07-06 +
Datasette plugin for enabling full-text search against selected table columns +* **[datasette-search-all](https://github.com/simonw/datasette-search-all)**: [0.3](https://github.com/simonw/datasette-search-all/releases/tag/0.3) - 2020-07-06 +
Datasette plugin for searching all searchable tables at once +* **[datasette-write](https://github.com/simonw/datasette-write)**: [0.1](https://github.com/simonw/datasette-write/releases/tag/0.1) - 2020-07-01 +
Datasette plugin providing a UI for writing to the database +* **[datasette-saved-queries](https://github.com/simonw/datasette-saved-queries)**: [0.2](https://github.com/simonw/datasette-saved-queries/releases/tag/0.2) - 2020-07-01 +
Datasette plugin that lets users save and execute queries +* **[datasette-glitch](https://github.com/simonw/datasette-glitch)**: [0.1](https://github.com/simonw/datasette-glitch/releases/tag/0.1) - 2020-07-01 +
Utilities to help run Datasette on Glitch +* **[datasette-init](https://github.com/simonw/datasette-init)**: [0.2](https://github.com/simonw/datasette-init/releases/tag/0.2) - 2020-07-01 +
Ensure specific tables and views exist on startup +* **[datasette](https://github.com/simonw/datasette)**: [0.45](https://github.com/simonw/datasette/releases/tag/0.45) - 2020-07-01 +
An open source multi-tool for exploring and publishing data +* **[asgi-csrf](https://github.com/simonw/asgi-csrf)**: [0.6](https://github.com/simonw/asgi-csrf/releases/tag/0.6) - 2020-07-01 +
ASGI middleware for protecting against CSRF attacks +* **[datasette-allow-permissions-debug](https://github.com/simonw/datasette-allow-permissions-debug)**: [0.1](https://github.com/simonw/datasette-allow-permissions-debug/releases/tag/0.1) - 2020-06-30 +
Always allow access to /-/permissions, for debugging +* **[datasette-debug-asgi](https://github.com/simonw/datasette-debug-asgi)**: [0.1.1](https://github.com/simonw/datasette-debug-asgi/releases/tag/0.1.1) - 2020-06-29 +
Datasette plugin for dumping out the ASGI scope +* **[sqlite-generate](https://github.com/simonw/sqlite-generate)**: [1.1.1](https://github.com/simonw/sqlite-generate/releases/tag/1.1.1) - 2020-06-23 +
Tool for generating demo SQLite databases +* **[datasette-block-robots](https://github.com/simonw/datasette-block-robots)**: [0.1.1](https://github.com/simonw/datasette-block-robots/releases/tag/0.1.1) - 2020-06-23 +
Datasette plugin that blocks all robots using robots.txt +* **[click-app-template-demo](https://github.com/simonw/click-app-template-demo)**: [0.1](https://github.com/simonw/click-app-template-demo/releases/tag/0.1) - 2020-06-22 +
Demo for https://github.com/simonw/click-app +* **[datasette-plugin-template-demo](https://github.com/simonw/datasette-plugin-template-demo)**: [0.1](https://github.com/simonw/datasette-plugin-template-demo/releases/tag/0.1) - 2020-06-19 +
Demonstrating https://github.com/simonw/datasette-plugin +* **[datasette-psutil](https://github.com/simonw/datasette-psutil)**: [0.2](https://github.com/simonw/datasette-psutil/releases/tag/0.2) - 2020-06-13 +
Datasette plugin adding a /-/psutil debugging endpoint +* **[datasette-permissions-sql](https://github.com/simonw/datasette-permissions-sql)**: [0.3a](https://github.com/simonw/datasette-permissions-sql/releases/tag/0.3a) - 2020-06-12 +
Datasette plugin for configuring permission checks using SQL queries +* **[asgi-auth-github](https://github.com/simonw/asgi-auth-github)**: [0.1](https://github.com/simonw/asgi-auth-github/releases/tag/0.1) - 2020-06-10 +
ASGI middleware that authenticates users against GitHub +* **[datasette-ics](https://github.com/simonw/datasette-ics)**: [0.4](https://github.com/simonw/datasette-ics/releases/tag/0.4) - 2020-05-29 +
Datasette plugin for outputting iCalendar files +* **[datasette-atom](https://github.com/simonw/datasette-atom)**: [0.6](https://github.com/simonw/datasette-atom/releases/tag/0.6) - 2020-05-28 +
Datasette plugin that adds a .atom output format +* **[datasette-cluster-map](https://github.com/simonw/datasette-cluster-map)**: [0.10](https://github.com/simonw/datasette-cluster-map/releases/tag/0.10) - 2020-05-21 +
Datasette plugin that shows a cluster map for any data with latitude/longitude columns +* **[datasette-render-markdown](https://github.com/simonw/datasette-render-markdown)**: [1.1.2](https://github.com/simonw/datasette-render-markdown/releases/tag/1.1.2) - 2020-05-02 +
Datasette plugin for rendering Markdown +* **[conditional-get](https://github.com/simonw/conditional-get)**: [0.2a](https://github.com/simonw/conditional-get/releases/tag/0.2a) - 2020-04-30 +
CLI tool for fetching data using HTTP conditional get +* **[datasette-template-sql](https://github.com/simonw/datasette-template-sql)**: [1.0.1](https://github.com/simonw/datasette-template-sql/releases/tag/1.0.1) - 2020-04-22 +
Datasette plugin for executing SQL queries from templates +* **[datasette-auth-existing-cookies](https://github.com/simonw/datasette-auth-existing-cookies)**: [0.7](https://github.com/simonw/datasette-auth-existing-cookies/releases/tag/0.7) - 2020-04-15 +
Datasette plugin that authenticates users based on existing domain cookies +* **[paginate-json](https://github.com/simonw/paginate-json)**: [0.3](https://github.com/simonw/paginate-json/releases/tag/0.3) - 2020-04-14 +
Command-line tool for fetching JSON from paginated APIs +* **[datasette-mask-columns](https://github.com/simonw/datasette-mask-columns)**: [0.2](https://github.com/simonw/datasette-mask-columns/releases/tag/0.2) - 2020-04-14 +
Datasette plugin that masks specified database columns +* **[datasette-auth-github](https://github.com/simonw/datasette-auth-github)**: [0.12](https://github.com/simonw/datasette-auth-github/releases/tag/0.12) - 2020-04-10 +
Datasette plugin that authenticates users against GitHub +* **[datasette-jq](https://github.com/simonw/datasette-jq)**: [0.2.1](https://github.com/simonw/datasette-jq/releases/tag/0.2.1) - 2020-04-09 +
Datasette plugin that adds a custom SQL function for executing jq expressions against JSON values +* **[swarm-to-sqlite](https://github.com/dogsheep/swarm-to-sqlite)**: [0.3.1](https://github.com/dogsheep/swarm-to-sqlite/releases/tag/0.3.1) - 2020-03-28 +
Create a SQLite database containing your checkin history from Foursquare Swarm +* **[healthkit-to-sqlite](https://github.com/dogsheep/healthkit-to-sqlite)**: [0.5](https://github.com/dogsheep/healthkit-to-sqlite/releases/tag/0.5) - 2020-03-28 +
Convert an Apple Healthkit export zip to a SQLite database +* **[inaturalist-to-sqlite](https://github.com/dogsheep/inaturalist-to-sqlite)**: [0.2](https://github.com/dogsheep/inaturalist-to-sqlite/releases/tag/0.2) - 2020-03-24 +
Create a SQLite database containing your observation history from iNaturalist +* **[hacker-news-to-sqlite](https://github.com/dogsheep/hacker-news-to-sqlite)**: [0.3.1](https://github.com/dogsheep/hacker-news-to-sqlite/releases/tag/0.3.1) - 2020-03-21 +
Create a SQLite database containing data pulled from Hacker News +* **[datasette-render-html](https://github.com/simonw/datasette-render-html)**: [0.1.2](https://github.com/simonw/datasette-render-html/releases/tag/0.1.2) - 2020-03-21 +
Plugin for selectively rendering the HTML is specific columns +* **[datasette-render-timestamps](https://github.com/simonw/datasette-render-timestamps)**: [1.0.1](https://github.com/simonw/datasette-render-timestamps/releases/tag/1.0.1) - 2020-03-21 +
Datasette plugin for rendering timestamps +* **[datasette-show-errors](https://github.com/simonw/datasette-show-errors)**: [0.2](https://github.com/simonw/datasette-show-errors/releases/tag/0.2) - 2020-03-21 +
Datasette plugin for displaying error tracebacks +* **[datasette-column-inspect](https://github.com/simonw/datasette-column-inspect)**: [0.1a](https://github.com/simonw/datasette-column-inspect/releases/tag/0.1a) - 2020-03-09 +
Experimental plugin that adds a column inspector +* **[fec-to-sqlite](https://github.com/simonw/fec-to-sqlite)**: [0.2](https://github.com/simonw/fec-to-sqlite/releases/tag/0.2) - 2020-03-07 +
Save FEC campaign finance data to a SQLite database +* **[datasette-upload-csvs](https://github.com/simonw/datasette-upload-csvs)**: [0.4](https://github.com/simonw/datasette-upload-csvs/releases/tag/0.4) - 2020-03-03 +
Datasette plugin for uploading CSV files and converting them to a database table +* **[csv-diff](https://github.com/simonw/csv-diff)**: [0.6](https://github.com/simonw/csv-diff/releases/tag/0.6) - 2020-02-29 +
Python CLI tool and library for diffing CSV files +* **[asgi-log-to-sqlite](https://github.com/simonw/asgi-log-to-sqlite)**: [0.1.1](https://github.com/simonw/asgi-log-to-sqlite/releases/tag/0.1.1) - 2020-02-24 +
ASGI middleware for logging traffic to a SQLite database +* **[shapefile-to-sqlite](https://github.com/simonw/shapefile-to-sqlite)**: [0.2](https://github.com/simonw/shapefile-to-sqlite/releases/tag/0.2) - 2020-02-19 +
Load shapefiles into a SQLite (optionally SpatiaLite) database +* **[geojson-to-sqlite](https://github.com/simonw/geojson-to-sqlite)**: [0.2](https://github.com/simonw/geojson-to-sqlite/releases/tag/0.2) - 2020-02-11 +
CLI tool for converting GeoJSON files to SQLite (with SpatiaLite) +* **[datasette-sentry](https://github.com/simonw/datasette-sentry)**: [0.1.1](https://github.com/simonw/datasette-sentry/releases/tag/0.1.1) - 2020-01-29 +
Datasette plugin for configuring Sentry +* **[yaml-to-sqlite](https://github.com/simonw/yaml-to-sqlite)**: [0.3](https://github.com/simonw/yaml-to-sqlite/releases/tag/0.3) - 2019-11-29 +
Utility for converting YAML files to SQLite +* **[sqlite-transform](https://github.com/simonw/sqlite-transform)**: [0.3](https://github.com/simonw/sqlite-transform/releases/tag/0.3) - 2019-11-04 +
Tool for running transformations on columns in a SQLite database +* **[datasette-leaflet-geojson](https://github.com/simonw/datasette-leaflet-geojson)**: [0.4](https://github.com/simonw/datasette-leaflet-geojson/releases/tag/0.4) - 2019-11-02 +
Datasette plugin that replaces any GeoJSON column values with a Leaflet map. +* **[genome-to-sqlite](https://github.com/dogsheep/genome-to-sqlite)**: [0.1](https://github.com/dogsheep/genome-to-sqlite/releases/tag/0.1) - 2019-09-19 +
Import your genome into a SQLite database +* **[datasette-rure](https://github.com/simonw/datasette-rure)**: [0.3](https://github.com/simonw/datasette-rure/releases/tag/0.3) - 2019-09-11 +
Datasette plugin that adds a custom SQL function for executing matches using the Rust regular expression engine +* **[csvs-to-sqlite](https://github.com/simonw/csvs-to-sqlite)**: [1.0](https://github.com/simonw/csvs-to-sqlite/releases/tag/1.0) - 2019-08-03 +
Convert CSV files into a SQLite database +* **[datasette-cors](https://github.com/simonw/datasette-cors)**: [0.3](https://github.com/simonw/datasette-cors/releases/tag/0.3) - 2019-07-11 +
Datasette plugin for configuring CORS headers +* **[sqlite-diffable](https://github.com/simonw/sqlite-diffable)**: [0.2](https://github.com/simonw/sqlite-diffable/releases/tag/0.2) - 2019-07-04 +
Tools for dumping/loading a SQLite database to diffable directory structure +* **[datasette-json-html](https://github.com/simonw/datasette-json-html)**: [0.5 - tooltips and demos](https://github.com/simonw/datasette-json-html/releases/tag/0.5) - 2019-06-14 +
Datasette plugin for rendering HTML based on JSON values +* **[datasette-render-binary](https://github.com/simonw/datasette-render-binary)**: [0.3](https://github.com/simonw/datasette-render-binary/releases/tag/0.3) - 2019-06-13 +
Datasette plugin for rendering binary data +* **[datasette-bplist](https://github.com/simonw/datasette-bplist)**: [0.1](https://github.com/simonw/datasette-bplist/releases/tag/0.1) - 2019-06-09 +
Datasette plugin for working with Apple's binary plist format +* **[asgi-cors](https://github.com/simonw/asgi-cors)**: [0.2](https://github.com/simonw/asgi-cors/releases/tag/0.2) - 2019-05-07 +
ASGI middleware for applying CORS headers to an ASGI application +* **[sqlite-fts4](https://github.com/simonw/sqlite-fts4)**: [0.5.2](https://github.com/simonw/sqlite-fts4/releases/tag/0.5.2) - 2019-01-09 +
Custom Python functions for working with SQLite FTS4 +* **[datasette-vega](https://github.com/simonw/datasette-vega)**: [0.6.1](https://github.com/simonw/datasette-vega/releases/tag/0.6.1) - 2018-07-10 +
Datasette plugin for visualizing data using Vega + diff --git a/update_plugins_readme.py b/update_plugins_readme.py index 1c190d0..30cc8f3 100644 --- a/update_plugins_readme.py +++ b/update_plugins_readme.py @@ -28,25 +28,116 @@ def extract_repo_info(url): return parts[-2], parts[-1] +def _parse_first_int(text): + if not text: + return None + m = re.search(r"(\d[\d,]*)", text) + if not m: + return None + try: + return int(m.group(1).replace(",", "")) + except Exception: + return None + + +def fetch_repo_info_from_html(owner, repo): + """Best-effort fallback using the public GitHub HTML page.""" + url = f"https://github.com/{owner}/{repo}" + try: + response = httpx.get(url, headers={"User-Agent": "soderlind-readme-updater"}, timeout=10.0) + if response.status_code != 200: + return {"description": "", "stars": 0, "issues": 0} + + html = response.text + + # Description + description = "" + m = re.search(r'', html) + if m: + description = m.group(1).strip() + + # Stars (try a couple of common patterns) + stars = 0 + m = re.search(r'href="/' + re.escape(owner) + r'/' + re.escape(repo) + r'/stargazers"[^>]*>\s*([\d,]+)\s*<', html) + if m: + stars = _parse_first_int(m.group(1)) or 0 + else: + m = re.search(r'aria-label="([\d,]+)\s+users?\s+starred\s+this\s+repository"', html) + if m: + stars = _parse_first_int(m.group(1)) or 0 + + # Issues (issues only, displayed on the Issues tab) + issues = 0 + m = re.search( + r'href="/' + re.escape(owner) + r'/' + re.escape(repo) + r'/issues"[^>]*>\s*Issues\s*]*class="Counter"[^>]*>\s*([\d,]+)\s*', + html, + ) + if m: + issues = _parse_first_int(m.group(1)) or 0 + + return {"description": description or "", "stars": stars, "issues": issues} + except Exception: + return {"description": "", "stars": 0, "issues": 0} + + def fetch_repo_info(owner, repo, token): """Fetch repository name, description, stars and creation date from GitHub API.""" headers = {} if token: headers["Authorization"] = f"Bearer {token}" headers["Accept"] = "application/vnd.github.v3+json" + headers["User-Agent"] = "soderlind-readme-updater" url = f"https://api.github.com/repos/{owner}/{repo}" - response = httpx.get(url, headers=headers) + response = httpx.get(url, headers=headers, timeout=10.0) if response.status_code == 200: data = response.json() + + # `open_issues_count` includes PRs. We use Search API to get issues-only when + # authenticated; otherwise (or on failure), fall back to this number. + issues_fallback = int(data.get("open_issues_count", 0) or 0) + issues = issues_fallback + if token: + issues = fetch_open_issue_count(owner, repo, token, fallback=issues_fallback) + return { "name": data.get("name", repo), "description": data.get("description", "") or "", "stars": data.get("stargazers_count", 0), - "created_at": data.get("created_at", "") + "created_at": data.get("created_at", ""), + "issues": issues, } - return {"name": repo, "description": "", "stars": 0, "created_at": ""} + # Fall back to scraping public HTML (useful when unauthenticated + rate-limited). + html_info = fetch_repo_info_from_html(owner, repo) + return { + "name": repo, + "description": html_info.get("description", "") or "", + "stars": int(html_info.get("stars", 0) or 0), + "created_at": "", + "issues": int(html_info.get("issues", 0) or 0), + } + + +def fetch_open_issue_count(owner, repo, token, fallback=0): + """Fetch open issue count (issues only, excludes PRs) via GitHub Search API.""" + headers = {} + if token: + headers["Authorization"] = f"Bearer {token}" + headers["Accept"] = "application/vnd.github.v3+json" + headers["User-Agent"] = "soderlind-readme-updater" + + # Search API supports filtering PRs out by using `type:issue`. + q = f"repo:{owner}/{repo} type:issue state:open" + url = "https://api.github.com/search/issues" + try: + response = httpx.get(url, headers=headers, params={"q": q}, timeout=10.0) + if response.status_code == 200: + data = response.json() + return int(data.get("total_count", 0) or 0) + except Exception: + pass + return int(fallback or 0) def format_repo_name(repo_name): @@ -114,9 +205,11 @@ def generate_html_table(repos): def build_cell(repo): stars = repo.get("stars", 0) stars_text = f" ⭐ {stars}" if stars > 0 else "" + issues = repo.get("issues", 0) + issues_text = f" 🐛 {issues}" if issues and issues > 0 else "" return ( f'
\n' - f'
{repo["name"]}{stars_text}
\n' + f'
{repo["name"]}{stars_text}{issues_text}
\n' f'
{repo["description"]}
\n' f'
' ) @@ -125,8 +218,10 @@ def build_cell(repo): if promoted_repo: stars = promoted_repo.get("stars", 0) stars_text = f" ⭐ {stars}" if stars > 0 else "" + issues = promoted_repo.get("issues", 0) + issues_text = f" 🐛 {issues}" if issues and issues > 0 else "" promo_html = ( - f'

🚀 {promoted_repo["name"]}{stars_text}

\n' + f'

🚀 {promoted_repo["name"]}{stars_text}{issues_text}

\n' f'

{promoted_repo["description"]}

' ) rows.append(