Skip to content

Commit dda83cf

Browse files
authored
Merge pull request #19 from SillyLittleTech/copilot/feat-preserve-formatting-indep-wikis
feat: Properly Redirect Indie Wikies to specific pages
2 parents e09b771 + f78d5a4 commit dda83cf

9 files changed

Lines changed: 154 additions & 42 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: "Flean Swift CodeQL"
2+
3+
paths:
4+
- ios
5+
- mos

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
version: 2
77
updates:
8-
- package-ecosystem: "" # See documentation for possible values
9-
directory: "/" # Location of package manifests
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
1010
schedule:
1111
interval: "weekly"

.github/workflows/codeql.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CodeQL (Swift)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**.swift'
9+
- 'ios/**'
10+
- 'mos/**'
11+
- '.github/workflows/codeql.yml'
12+
- '.github/codeql/**'
13+
pull_request:
14+
branches:
15+
- main
16+
paths:
17+
- '**.swift'
18+
- 'ios/**'
19+
- 'mos/**'
20+
- '.github/workflows/codeql.yml'
21+
- '.github/codeql/**'
22+
schedule:
23+
- cron: '0 8 * * 1'
24+
workflow_dispatch:
25+
26+
permissions:
27+
contents: read
28+
security-events: write
29+
30+
jobs:
31+
analyze:
32+
name: Analyze
33+
runs-on: macos-latest
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v3
43+
with:
44+
languages: swift
45+
config-file: ./.github/codeql/codeql-config.yml
46+
47+
# The projects do not contain shared schemes, so build with explicit targets.
48+
- name: Build iOS app for analysis
49+
run: |
50+
cd ios
51+
xcodebuild build \
52+
-project Flean.xcodeproj \
53+
-target Flean \
54+
-configuration Debug \
55+
-sdk iphonesimulator \
56+
-skipPackagePluginValidation \
57+
CODE_SIGNING_ALLOWED=NO \
58+
CODE_SIGNING_REQUIRED=NO \
59+
CODE_SIGN_IDENTITY=""
60+
61+
- name: Build macOS app for analysis
62+
run: |
63+
cd mos
64+
xcodebuild build \
65+
-project Flean.xcodeproj \
66+
-target Flean \
67+
-configuration Debug \
68+
-sdk macosx \
69+
-skipPackagePluginValidation \
70+
CODE_SIGNING_ALLOWED=NO \
71+
CODE_SIGNING_REQUIRED=NO \
72+
CODE_SIGN_IDENTITY=""
73+
74+
- name: Perform CodeQL Analysis
75+
uses: github/codeql-action/analyze@v3
76+
with:
77+
category: '/language:swift'

ios/Flean.xcodeproj/project.pbxproj

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
isa = XCBuildConfiguration;
382382
buildSettings = {
383383
CODE_SIGN_STYLE = Automatic;
384-
CURRENT_PROJECT_VERSION = 3;
384+
CURRENT_PROJECT_VERSION = 4;
385385
DEVELOPMENT_ASSET_PATHS = extention;
386386
DEVELOPMENT_TEAM = PWL627GZ4Y;
387387
GENERATE_INFOPLIST_FILE = YES;
@@ -394,7 +394,7 @@
394394
"@executable_path/Frameworks",
395395
"@executable_path/../../Frameworks",
396396
);
397-
MARKETING_VERSION = 2.1.6;
397+
MARKETING_VERSION = 2.2.0;
398398
OTHER_LDFLAGS = (
399399
"-framework",
400400
SafariServices,
@@ -417,7 +417,7 @@
417417
isa = XCBuildConfiguration;
418418
buildSettings = {
419419
CODE_SIGN_STYLE = Automatic;
420-
CURRENT_PROJECT_VERSION = 3;
420+
CURRENT_PROJECT_VERSION = 4;
421421
DEVELOPMENT_ASSET_PATHS = extention;
422422
DEVELOPMENT_TEAM = PWL627GZ4Y;
423423
GENERATE_INFOPLIST_FILE = YES;
@@ -430,7 +430,7 @@
430430
"@executable_path/Frameworks",
431431
"@executable_path/../../Frameworks",
432432
);
433-
MARKETING_VERSION = 2.1.6;
433+
MARKETING_VERSION = 2.2.0;
434434
OTHER_LDFLAGS = (
435435
"-framework",
436436
SafariServices,
@@ -577,7 +577,7 @@
577577
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
578578
CODE_SIGN_ENTITLEMENTS = Flean/Flean.entitlements;
579579
CODE_SIGN_STYLE = Automatic;
580-
CURRENT_PROJECT_VERSION = 3;
580+
CURRENT_PROJECT_VERSION = 4;
581581
DEVELOPMENT_TEAM = PWL627GZ4Y;
582582
GENERATE_INFOPLIST_FILE = YES;
583583
INFOPLIST_KEY_CFBundleDisplayName = Flean;
@@ -588,7 +588,7 @@
588588
"$(inherited)",
589589
"@executable_path/Frameworks",
590590
);
591-
MARKETING_VERSION = 2.1.6;
591+
MARKETING_VERSION = 2.2.0;
592592
OTHER_LDFLAGS = (
593593
"-framework",
594594
SafariServices,
@@ -613,7 +613,7 @@
613613
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
614614
CODE_SIGN_ENTITLEMENTS = Flean/Flean.entitlements;
615615
CODE_SIGN_STYLE = Automatic;
616-
CURRENT_PROJECT_VERSION = 3;
616+
CURRENT_PROJECT_VERSION = 4;
617617
DEVELOPMENT_TEAM = PWL627GZ4Y;
618618
GENERATE_INFOPLIST_FILE = YES;
619619
INFOPLIST_KEY_CFBundleDisplayName = Flean;
@@ -624,7 +624,7 @@
624624
"$(inherited)",
625625
"@executable_path/Frameworks",
626626
);
627-
MARKETING_VERSION = 2.1.6;
627+
MARKETING_VERSION = 2.2.0;
628628
OTHER_LDFLAGS = (
629629
"-framework",
630630
SafariServices,
@@ -647,11 +647,11 @@
647647
buildSettings = {
648648
BUNDLE_LOADER = "$(TEST_HOST)";
649649
CODE_SIGN_STYLE = Automatic;
650-
CURRENT_PROJECT_VERSION = 3;
650+
CURRENT_PROJECT_VERSION = 4;
651651
DEVELOPMENT_TEAM = PWL627GZ4Y;
652652
GENERATE_INFOPLIST_FILE = YES;
653653
MACOSX_DEPLOYMENT_TARGET = 10.14;
654-
MARKETING_VERSION = 2.1.6;
654+
MARKETING_VERSION = 2.2.0;
655655
PRODUCT_BUNDLE_IDENTIFIER = slf.FleanTests;
656656
PRODUCT_NAME = "$(TARGET_NAME)";
657657
SWIFT_EMIT_LOC_STRINGS = NO;
@@ -665,11 +665,11 @@
665665
buildSettings = {
666666
BUNDLE_LOADER = "$(TEST_HOST)";
667667
CODE_SIGN_STYLE = Automatic;
668-
CURRENT_PROJECT_VERSION = 3;
668+
CURRENT_PROJECT_VERSION = 4;
669669
DEVELOPMENT_TEAM = PWL627GZ4Y;
670670
GENERATE_INFOPLIST_FILE = YES;
671671
MACOSX_DEPLOYMENT_TARGET = 10.14;
672-
MARKETING_VERSION = 2.1.6;
672+
MARKETING_VERSION = 2.2.0;
673673
PRODUCT_BUNDLE_IDENTIFIER = slf.FleanTests;
674674
PRODUCT_NAME = "$(TARGET_NAME)";
675675
SWIFT_EMIT_LOC_STRINGS = NO;
@@ -682,10 +682,10 @@
682682
isa = XCBuildConfiguration;
683683
buildSettings = {
684684
CODE_SIGN_STYLE = Automatic;
685-
CURRENT_PROJECT_VERSION = 3;
685+
CURRENT_PROJECT_VERSION = 4;
686686
DEVELOPMENT_TEAM = PWL627GZ4Y;
687687
GENERATE_INFOPLIST_FILE = YES;
688-
MARKETING_VERSION = 2.1.6;
688+
MARKETING_VERSION = 2.2.0;
689689
PRODUCT_BUNDLE_IDENTIFIER = slf.FleanUITests;
690690
PRODUCT_NAME = "$(TARGET_NAME)";
691691
SWIFT_EMIT_LOC_STRINGS = NO;
@@ -698,10 +698,10 @@
698698
isa = XCBuildConfiguration;
699699
buildSettings = {
700700
CODE_SIGN_STYLE = Automatic;
701-
CURRENT_PROJECT_VERSION = 3;
701+
CURRENT_PROJECT_VERSION = 4;
702702
DEVELOPMENT_TEAM = PWL627GZ4Y;
703703
GENERATE_INFOPLIST_FILE = YES;
704-
MARKETING_VERSION = 2.1.6;
704+
MARKETING_VERSION = 2.2.0;
705705
PRODUCT_BUNDLE_IDENTIFIER = slf.FleanUITests;
706706
PRODUCT_NAME = "$(TARGET_NAME)";
707707
SWIFT_EMIT_LOC_STRINGS = NO;

ios/extention/Resources/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"name": "Flean Extension",
66
"description": "Redirect Fandom wiki pages to independent mirrors.",
7-
"version": "2.1.6",
7+
"version": "2.2.0",
88

99
"icons": {
1010
"48": "images/icon-48.png",

ios/extention/Resources/scripts/wiki-data-manager.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,36 @@ export async function findMatchingWiki (urlString) {
163163
}
164164
try { article = decodeURIComponent(article) } catch { /* keep encoded */ }
165165

166+
// If the article is empty (wiki root) or matches the origin's main page, redirect to
167+
// the destination's declared main page to honour cross-wiki naming differences.
168+
if (wiki.destination_main_page) {
169+
const normalize = title => (title || '').replace(/_/g, ' ').toLowerCase().trim()
170+
if (!article || normalize(article) === normalize(originEntry.origin_main_page || '')) {
171+
article = wiki.destination_main_page
172+
}
173+
}
174+
166175
// Build destination URL based on platform
167176
const destBase = wiki.destination_base_url
168177
.replace(/^https?:\/\//, '')
169178
.replace(/\/$/, '')
170179
const platform = (wiki.destination_platform || 'mediawiki').toLowerCase()
171180
let destPath = ''
181+
const encodedArticle = encodeURIComponent(article.replace(/ /g, '_'))
172182

173183
if (wiki.destination_content_path) {
174-
destPath = wiki.destination_content_path
175-
.replace('$1', encodeURIComponent(article.replace(/ /g, '_')))
184+
if (wiki.destination_content_path.includes('$1')) {
185+
// Template-style path: replace the $1 placeholder with the article name
186+
destPath = wiki.destination_content_path.replace('$1', encodedArticle)
187+
} else {
188+
// Prefix-style path (e.g. "/wiki/"): append the article name to the prefix
189+
destPath = wiki.destination_content_path + encodedArticle
190+
}
176191
} else if (platform === 'dokuwiki') {
177192
destPath = `/doku.php?id=${encodeURIComponent(article.replace(/ /g, '_').toLowerCase())}`
178193
} else {
179194
// Default: MediaWiki-style /wiki/ArticleName
180-
destPath = `/wiki/${encodeURIComponent(article.replace(/ /g, '_'))}`
195+
destPath = `/wiki/${encodedArticle}`
181196
}
182197

183198
const destinationUrl = `https://${destBase}${destPath}${url.search}${url.hash}`

mos/Flean Extension/Resources/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"name": "__MSG_extension_name__",
66
"description": "__MSG_extension_description__",
7-
"version": "2.1.6",
7+
"version": "2.2.0",
88

99
"icons": {
1010
"48": "images/icon-48.png",

mos/Flean Extension/Resources/scripts/wiki-data-manager.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,36 @@ export async function findMatchingWiki (urlString) {
163163
}
164164
try { article = decodeURIComponent(article) } catch { /* keep encoded */ }
165165

166+
// If the article is empty (wiki root) or matches the origin's main page, redirect to
167+
// the destination's declared main page to honour cross-wiki naming differences.
168+
if (wiki.destination_main_page) {
169+
const normalize = title => (title || '').replace(/_/g, ' ').toLowerCase().trim()
170+
if (!article || normalize(article) === normalize(originEntry.origin_main_page || '')) {
171+
article = wiki.destination_main_page
172+
}
173+
}
174+
166175
// Build destination URL based on platform
167176
const destBase = wiki.destination_base_url
168177
.replace(/^https?:\/\//, '')
169178
.replace(/\/$/, '')
170179
const platform = (wiki.destination_platform || 'mediawiki').toLowerCase()
171180
let destPath = ''
181+
const encodedArticle = encodeURIComponent(article.replace(/ /g, '_'))
172182

173183
if (wiki.destination_content_path) {
174-
destPath = wiki.destination_content_path
175-
.replace('$1', encodeURIComponent(article.replace(/ /g, '_')))
184+
if (wiki.destination_content_path.includes('$1')) {
185+
// Template-style path: replace the $1 placeholder with the article name
186+
destPath = wiki.destination_content_path.replace('$1', encodedArticle)
187+
} else {
188+
// Prefix-style path (e.g. "/wiki/"): append the article name to the prefix
189+
destPath = wiki.destination_content_path + encodedArticle
190+
}
176191
} else if (platform === 'dokuwiki') {
177192
destPath = `/doku.php?id=${encodeURIComponent(article.replace(/ /g, '_').toLowerCase())}`
178193
} else {
179194
// Default: MediaWiki-style /wiki/ArticleName
180-
destPath = `/wiki/${encodeURIComponent(article.replace(/ /g, '_'))}`
195+
destPath = `/wiki/${encodedArticle}`
181196
}
182197

183198
const destinationUrl = `https://${destBase}${destPath}${url.search}${url.hash}`

0 commit comments

Comments
 (0)