Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ocp-apifetch
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Dec 4, 2024
2 parents 87971fa + 4176de1 commit b343c5f
Show file tree
Hide file tree
Showing 27 changed files with 5,533 additions and 4,668 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WEB_EXT_API_KEY=
WEB_EXT_API_SECRET=
27 changes: 15 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ name: CI

on:
push:
branches: [ master ]
branches:
- master
pull_request:
branches: [ master ]
branches:
- master

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 14
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Install dependencies
run: npm ci
- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
- name: Run tests
run: npm test
18 changes: 16 additions & 2 deletions .github/workflows/gh-pages-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ on:
branches:
- 'master'
paths:
- 'Extensions/dist/'
- 'Extensions/dist/*'
workflow_dispatch:

permissions:
contents: write

jobs:
build:
Expand All @@ -25,4 +29,14 @@ jobs:
run: npm ci

- name: Update gh-pages
run: npx gh-pages --add --dist . --src "Extensions/dist/"
run: >
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages
-u "github-actions-bot <[email protected]>"
--add
--dist .
--src "Extensions/dist/"
--message 'Update Extensions/dist/'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Rebuild Distribution (7.9.2)

on:
push:
branches:
- '7.9.2'
paths:
- 'Extensions/*'
- 'Themes/*'
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Autobuild extensions
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 14
cache: npm

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Install gulp-cli
run: npm install gulp-cli

- name: Build distribution
run: gulp build

- name: Push changes to gh-pages
run: >
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages
-u "github-actions-bot <[email protected]>"
--add
--dist .
--src "{Extensions/dist/*.json,Extensions/dist/page/gallery.json,Extensions/dist/page/list.json,Extensions/dist/page/themes.json}"
--message 'Rebuild Distribution'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/release-after-signing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Generate Release (after signing)

on:
workflow_dispatch:

permissions:
contents: write

jobs:
release:
name: Generate Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- run: npm ci

### NOTE: This workflow continues the "Generate Release" workflow if it timed out.

- name: Firefox — Download Latest Signed XPI
run: node dev/download_signed_xpi.mjs
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}

- name: Get Release Version
uses: actions/github-script@v7
id: get-version
with:
result-encoding: string
script: |
const fs = require('node:fs');
const { version } = JSON.parse(fs.readFileSync(('${{ github.workspace }}/manifest.json')));
const files = fs
.readdirSync('${{ github.workspace }}/web-ext-artifacts')
.filter(filePath => filePath.endsWith(`${version}.xpi`));
if (files.length === 0) {
throw new Error(`Could not find signed v${version} XPI! Has Mozilla reviewed it?`);
}
const releases = await github.paginate(github.rest.repos.listReleases, { owner: context.repo.owner, repo: context.repo.repo, });
if (releases.some(({ tag_name }) => tag_name === `v${version}`)) {
throw new Error(`Release v${version} already exists! Did you forget to bump the manifest.json version?`);
}
return version;
# - name: Chrome — Build
# run: npm run build
# - name: Chrome — Upload and Publish
# run: npx chrome-webstore-upload --source=web-ext-artifacts/new_xkit-${{ steps.get-version.outputs.result }}.zip
# env:
# EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
# CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
# REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}

- name: Create Github release draft
uses: softprops/action-gh-release@v2
with:
name: New XKit ${{ steps.get-version.outputs.result }}
tag_name: v${{ steps.get-version.outputs.result }}
body: |
<!-- -->
**NOTE:** Firefox may complain about getting a connection error when clicking the below XPI link. If it does, right-click the link and select "Save Link As...", then navigate to `about:addons` and drag the file onto that screen to install New XKit.
For Chrome: Install from the [Chrome Web Store](https://new-xkit-extension.tumblr.com/chrome) instead of here.
files: web-ext-artifacts/*.xpi
draft: true
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Generate Release

on:
workflow_dispatch:

permissions:
contents: write

jobs:
sign-and-release:
name: Sign and Generate Release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- run: npm ci

- name: Lint WebExtension
run: npm run lint

- name: Get Release Version
uses: actions/github-script@v7
id: get-version
with:
result-encoding: string
script: |
const fs = require('node:fs');
const { version } = JSON.parse(fs.readFileSync(('${{ github.workspace }}/manifest.json')));
const releases = await github.paginate(github.rest.repos.listReleases, { owner: context.repo.owner, repo: context.repo.repo, });
if (releases.some(({ tag_name }) => tag_name === `v${version}`)) {
throw new Error(`Release v${version} already exists! Did you forget to bump the manifest.json version?`);
}
return version;
- name: Firefox — Build and Sign
run: npm run sign
timeout-minutes: 30
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
WEB_EXT_CHANNEL: unlisted

### NOTE: This workflow may time out here while waiting for Mozilla review.
### If this occurs, run the "Generate Release (after signing)" action once it is complete.

# - name: Chrome — Build
# run: npm run build
# - name: Chrome — Upload and Publish
# run: npx chrome-webstore-upload --source=web-ext-artifacts/new_xkit-${{ steps.get-version.outputs.result }}.zip
# env:
# EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
# CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
# CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
# REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}

- name: Create Github release draft
uses: softprops/action-gh-release@v2
with:
name: New XKit ${{ steps.get-version.outputs.result }}
tag_name: v${{ steps.get-version.outputs.result }}
body: |
<!-- -->
**NOTE:** Firefox may complain about getting a connection error when clicking the below XPI link. If it does, right-click the link and select "Save Link As...", then navigate to `about:addons` and drag the file onto that screen to install New XKit.
For Chrome: Install from the [Chrome Web Store](https://new-xkit-extension.tumblr.com/chrome) instead of here.
files: web-ext-artifacts/*.xpi
draft: true
37 changes: 37 additions & 0 deletions .github/workflows/update-release-metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update Release Metadata

on:
workflow_dispatch:
inputs:
newVersion:
description: version override
type: string
required: false

jobs:
create-update-pr:
name: Create update PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Update release metadata
run: node dev/update_release_metadata.mjs ${{ inputs.newVersion || '' }}

- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
title: Update release metadata
commit-message: update release metadata
branch: update-release-metadata
body: |
Updates the extension version in metadata files, triggering Firefox autoupdate and the "Please update XKit!" in-extension notification.
Remember to confirm that the referenced version is released on Github, the .xpi file link works, and the Chrome web store has the referenced version available before merging this.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ web-ext-artifacts/

*.iml
.idea/

.env
8 changes: 4 additions & 4 deletions Extensions/blacklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ XKit.extensions.blacklist = new Object({

if ($(this).find(".reblog-content").length > 0) {
m_content = $(this).find(".reblog-content").map(function() {
return $(this).html();
return $(this).html();
}).get().join(" ");
}

Expand All @@ -623,7 +623,7 @@ XKit.extensions.blacklist = new Object({
var content = $(this).find(contentSel);
if (content.length) {
m_content += content.map(function() {
return $(this).html();
return $(this).html();
}).get().join(" ");
}

Expand All @@ -636,8 +636,8 @@ XKit.extensions.blacklist = new Object({
m_content = XKit.tools.replace_all(m_content, "&nbsp;", " ");
m_content = m_content.toLowerCase();

// Preserve href links.
m_content = m_content.replace(/<a\s+(?:[^>]*?\s+)?href="([^"]*)".*?>/gm, ' $1 ');
// Preserve href links.
m_content = m_content.replace(/<a\s+(?:[^>]*?\s+)?href="([^"]*)".*?>/gm, ' $1 ');
// Strip HTML tags.
m_content = m_content.replace(/<(?:.|\n)*?>/gm, ' ');

Expand Down
10 changes: 5 additions & 5 deletions Extensions/classic_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ XKit.extensions.classic_tags = new Object({
value: false
},
"prepend_sidebar": {
text: "Put tags at top of sidebar",
default: false,
value: false
text: "Put tags at top of sidebar",
default: false,
value: false
},
"alphabetical_tags": {
text: "Sort tags alphabetically",
default: false,
value: false
default: false,
value: false
},
"sep-3": {
text: "Settings",
Expand Down
6 changes: 3 additions & 3 deletions Extensions/editable_reblogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ XKit.extensions.editable_reblogs = new Object({
if (!XKit.storage.get('editable_reblogs', 'has_dismissed_button_callout', '')) {
post_margin.append(
'<div class="xkit-er-callout--container">' +
'<div class="xkit-er-callout--header">Editable Reblogs</div>' +
'<div class="xkit-er-callout--body">click this button to trim or edit this post</div>' +
'<div class="xkit-er-callout--header">Editable Reblogs</div>' +
'<div class="xkit-er-callout--body">click this button to trim or edit this post</div>' +
'</div>'
);

Expand Down Expand Up @@ -566,7 +566,7 @@ XKit.extensions.editable_reblogs = new Object({

var github_url = XKit.tools.github_issue("Editable Reblogs posting error",
{ "ER Version": XKit.installed.get("editable_reblogs").version,
user: request.channel_id, body: request["post[two]"]}, {stack: response});
user: request.channel_id, body: request["post[two]"]}, {stack: response});

XKit.window.show("Error",
"Error: XER-SR.<br><br>There was an error reblogging your post. Please try again shortly. " +
Expand Down
Loading

0 comments on commit b343c5f

Please sign in to comment.