Skip to content

Commit d89ce68

Browse files
authored
Merge branch 'wikimedia:main' into develop
2 parents 1c79fa0 + 4f504ea commit d89ce68

File tree

2,433 files changed

+148906
-67269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,433 files changed

+148906
-67269
lines changed

.circleci/config.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/localization.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
update-localizations:
1717
runs-on: macOS-latest
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
2020

2121
- name: Update localizations
2222
continue-on-error: true

.github/workflows/post_phab.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Post to Phabricator
2+
3+
on:
4+
pull_request:
5+
types: [opened, closed]
6+
7+
jobs:
8+
post_to_phab:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Post to Phabricator when pull request is opened or closed
12+
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'closed') }}
13+
env:
14+
PR_BODY: ${{ github.event.pull_request.body }}
15+
run: |
16+
message="${{ github.actor }} ${{ github.event.action }} ${{ github.event.pull_request._links.html.href }}"
17+
echo -e "${PR_BODY}" | grep -oEi "(^Bug:\s*T[0-9]+)|(^([*]*phabricator[*]*:[*]*\s*)?https:\/\/phabricator\.wikimedia\.org\/T[0-9]+)" | grep -oEi "T[0-9]+" | while IFS= read -r line; do
18+
echo "Processing: $line"
19+
curl https://phabricator.wikimedia.org/api/maniphest.edit \
20+
-d api.token=${{ secrets.PHAB_BOT_API_KEY }} \
21+
-d transactions[0][type]=comment \
22+
-d transactions[0][value]="${message}" \
23+
-d objectIdentifier=${line}
24+
done

.github/workflows/tag_latest_beta.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tag Latest Beta
2+
3+
on:
4+
schedule:
5+
- cron: '0 10 * * *' # run at 10AM UTC
6+
workflow_dispatch: # allows workflow to be triggered manually
7+
8+
jobs:
9+
Tag-Latest-Beta:
10+
runs-on: macOS-latest
11+
steps:
12+
- name: Check out repository code
13+
uses: actions/checkout@v4
14+
- name: Get tags
15+
run: git fetch --tags origin
16+
- name: Checkout and pull latest
17+
run: |
18+
git checkout main
19+
git pull origin main
20+
- name: Move latest_beta tag
21+
run: |
22+
LATESTBETATAG='latest_beta'
23+
LASTBETASHA=$(git rev-parse $LATESTBETATAG)
24+
CURRENTSHA=$(git rev-parse HEAD) #origin/main?
25+
echo "${LASTBETASHA}"
26+
echo "${CURRENTSHA}"
27+
if [ ${LASTBETASHA} != ${CURRENTSHA} ]; then
28+
echo "New commit on main. Moving latest_beta tag."
29+
echo "Deleting old tag and pushing"
30+
git tag -d ${LATESTBETATAG}
31+
git push origin :refs/tags/${LATESTBETATAG}
32+
echo "Creating new tag and pushing"
33+
git tag ${LATESTBETATAG}
34+
git push --tags
35+
else
36+
echo "No new commits determined. Exiting."
37+
fi
38+
- run: echo "This job's status is ${{ job.status }}."

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "CodeMirror/wikipedia-ios-codemirror"]
2-
path = CodeMirror/wikipedia-ios-codemirror
3-
url = https://github.com/wikimedia/wikipedia-ios-codemirror.git

.mailmap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See: https://git-scm.com/docs/git-shortlog#_mapping_authors
2+
#
3+
Brooke Vibber <[email protected]>
4+
5+

.swiftlint-autocorrect.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ disabled_rules:
3232
- unneeded_break_in_switch
3333
- unused_closure_parameter
3434
- notification_center_detachment
35+
- non_optional_string_data_conversion
3536

3637
vertical_whitespace:
3738
max_empty_lines: 2

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ disabled_rules:
3232
- unneeded_break_in_switch
3333
- unused_closure_parameter
3434
- notification_center_detachment
35+
- non_optional_string_data_conversion
3536

3637
vertical_whitespace:
3738
max_empty_lines: 2

.xcversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ If you're ready to pick up more difficult work, look at the iOS backlog and pick
1515
Now you want to let the team know what you're working on.
1616

1717
1. In Phabricator, assign the task to yourself.
18-
2. Add the tag representing the current release to the task. [This link](https://phabricator.wikimedia.org/search/query/WlSMhOAWTG73/) will take you to currently open releases. Tagging your task with the name of the release will add it to the release board.
18+
2. Add the release tag "iOS Release FY2023-24" to the task. [This link](https://phabricator.wikimedia.org/project/board/7291/) will take you to our current release board. Tagging your task with the name of the release will add it to the release board.
1919
3. On the release board, move the task to the "Doing" column.
2020
4. When you're done developing, move the task to the "Needs Code Review" column.
2121

22+
## GitHub is not running unit tests on my pull request
23+
This is a known limitation with Xcode Cloud (see more details in [T358110](https://phabricator.wikimedia.org/T358110)). We will still review your PR, and a maintainer will confirm run tests locally before merging. Details on improvements we're planning can be found in [T362932](https://phabricator.wikimedia.org/T362932).
24+
2225
## I don't want to work on my task any more.
2326
You can let us know by unassigning the task and moving it back to the "Tasks from Product Backlog" column.
2427

CodeMirror/wikipedia-ios-codemirror

Lines changed: 0 additions & 1 deletion
This file was deleted.

Command Line Tools/Update Languages/WikipediaLanguageCommandLineUtility.swift

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ class WikipediaLanguageCommandLineUtility {
2929
}
3030
self.writeCodable(sortedSites, to: ["Wikipedia", "Code", "wikipedia-languages.json"])
3131
self.cancellable = self.writeNamespaceFiles(with: sites) {
32-
self.cancellable = self.writeCodemirrorConfig(with: sites, completion: {
33-
completion()
34-
})
32+
completion()
3533
}
3634
}
3735

@@ -55,25 +53,6 @@ class WikipediaLanguageCommandLineUtility {
5553
}
5654
}
5755

58-
private func writeCodemirrorConfig(with sites: [Wikipedia], completion: @escaping () -> Void) -> AnyCancellable {
59-
Publishers.MergeMany(sites.map { site in
60-
api.getCodeMirrorConfigJSON(for: site.languageCode)
61-
.map { ($0, site) }
62-
})
63-
.sink(receiveCompletion: { (result) in
64-
switch result {
65-
case .finished:
66-
break
67-
case .failure(let error):
68-
print("Error writing codemirror config: \(error)")
69-
}
70-
completion()
71-
}) { (value) in
72-
let outputURL = self.getOutputFileURL(with: ["Wikipedia", "assets", "codemirror", "config", "codemirror-config-\(value.1.languageCode).json"])
73-
try! value.0.write(to: outputURL, atomically: true, encoding: .utf8)
74-
}
75-
}
76-
7756
private func writeNamespaceFiles(with sites: [Wikipedia], completion: @escaping () -> Void) -> AnyCancellable? {
7857
return Publishers.MergeMany(sites.map { site in
7958
api.getSiteInfo(with: site.languageCode)
@@ -85,7 +64,8 @@ class WikipediaLanguageCommandLineUtility {
8564
.sink(receiveCompletion: { (result) in
8665
completion()
8766
}) { (siteInfoTuple) in
88-
self.writeCodable(siteInfoTuple.0, to: ["Wikipedia", "Code", "wikipedia-namespaces", "\(siteInfoTuple.1.languageCode).json"])
67+
self.writeCodable(siteInfoTuple.0.namespaceInfo, to: ["Wikipedia", "Code", "wikipedia-namespaces", "\(siteInfoTuple.1.languageCode).json"])
68+
self.writeCodable(siteInfoTuple.0.magicWordInfo, to: ["Wikipedia", "Code", "wikipedia-magicwords", "\(siteInfoTuple.1.languageCode).json"])
8969
}
9070
}
9171

@@ -101,6 +81,35 @@ class WikipediaLanguageCommandLineUtility {
10181
for namespaceAlias in siteInfo.query.namespacealiases {
10282
namespaces[namespaceAlias.alias.uppercased()] = PageNamespace(rawValue: namespaceAlias.id)
10383
}
104-
return WikipediaSiteInfoLookup(namespace: namespaces, mainpage: siteInfo.query.general.mainpage.uppercased())
84+
var recognizedMagicWords = siteInfo.query.magicwords.filter {
85+
return $0.name == "img_thumbnail" ||
86+
$0.name == "img_framed" ||
87+
$0.name == "img_frameless" ||
88+
$0.name == "img_right" ||
89+
$0.name == "img_left" ||
90+
$0.name == "img_center" ||
91+
$0.name == "img_none" ||
92+
$0.name == "img_alt" ||
93+
$0.name == "img_baseline" ||
94+
$0.name == "img_border" ||
95+
$0.name == "img_bottom" ||
96+
$0.name == "img_middle" ||
97+
$0.name == "img_sub" ||
98+
$0.name == "img_super" ||
99+
$0.name == "img_text_bottom" ||
100+
$0.name == "img_text_top" ||
101+
$0.name == "img_top" ||
102+
$0.name == "img_upright"
103+
}
104+
105+
let namespaceAliases = siteInfo.query.namespacealiases
106+
var fileNamespaceMagicWords = namespaceAliases.filter { $0.id == 6 }.map { $0.alias }
107+
if let fileNamespaceMagicWord = siteInfo.query.namespaces["6"]?.name {
108+
fileNamespaceMagicWords.insert(fileNamespaceMagicWord, at: 0)
109+
}
110+
recognizedMagicWords.append(MagicWord(name: "file_namespace", aliases: fileNamespaceMagicWords))
111+
112+
let namespaceInfo = WikipediaSiteInfoLookup.NamespaceInfo(namespace: namespaces, mainpage: siteInfo.query.general.mainpage.uppercased())
113+
return WikipediaSiteInfoLookup(namespaceInfo: namespaceInfo, magicWordInfo: recognizedMagicWords)
105114
}
106115
}

Command Line Tools/Update Languages/WikipediaLanguageCommandLineUtilityAPI.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,36 +54,23 @@ class WikipediaLanguageCommandLineUtilityAPI {
5454

5555
return Wikipedia(languageCode: code, languageName: name, localName: localname, altISOCode: nil)
5656
}
57-
// Add testwiki, it's not returned by the site matrix
57+
// Add testwiki and test2wiki, they are not returned by the site matrix
5858
wikipedias.append(Wikipedia(languageCode: "test", languageName: "Test", localName: "Test", altISOCode: nil))
59+
wikipedias.append(Wikipedia(languageCode: "test2", languageName: "Test 2", localName: "Test 2", altISOCode: nil))
5960
return wikipedias
6061
}.eraseToAnyPublisher()
6162
}
6263

6364
func getSiteInfo(with languageCode: String) -> AnyPublisher<SiteInfo, Error> {
64-
let siteInfoURL = URL(string: "https://\(languageCode).wikipedia.org/w/api.php?action=query&format=json&prop=&list=&meta=siteinfo&siprop=namespaces%7Cgeneral%7Cnamespacealiases&formatversion=2&origin=*")!
65+
let siteInfoURL = URL(string: "https://\(languageCode).wikipedia.org/w/api.php?action=query&format=json&prop=&list=&meta=siteinfo&siprop=namespaces%7Cgeneral%7Cnamespacealiases%7Cmagicwords&formatversion=2&origin=*")!
6566
return URLSession.shared
6667
.dataTaskPublisher(for: siteInfoURL)
6768
.tryMap { (result) -> SiteInfo in
6869
try JSONDecoder().decode(SiteInfo.self, from: result.data)
6970
}.eraseToAnyPublisher()
7071
}
7172

72-
func getCodeMirrorConfigJSON(for wikiLanguage: String) -> AnyPublisher<String, Error> {
73-
let codeMirrorConfigURL = URL(string: "http://\(wikiLanguage).wikipedia.org/w/load.php?debug=false&lang=en&modules=ext.CodeMirror.data")!
74-
return URLSession.shared.dataTaskPublisher(for: codeMirrorConfigURL)
75-
.tryMap { (result) -> String in
76-
guard
77-
let responseString = String(data: result.data, encoding: .utf8),
78-
let soughtSubstring = self.extractJSONString(from: responseString)
79-
else {
80-
throw WikipediaLanguageUtilityAPIError.generic
81-
}
82-
return soughtSubstring.replacingOccurrences(of: "!0", with: "true")
83-
}.eraseToAnyPublisher()
84-
}
85-
86-
private let jsonExtractionRegex = try! NSRegularExpression(pattern: #"(?:mw\.config\.set\()(.*?)(?:\);\n*\}\);)"#, options: [.dotMatchesLineSeparators])
73+
private let jsonExtractionRegex = try! NSRegularExpression(pattern: #"(?:mw\.config\.set\()(.*?)(?:\)\n*;\n*\}\);)"#, options: [.dotMatchesLineSeparators])
8774

8875
private func extractJSONString(from responseString: String) -> String? {
8976
let results = jsonExtractionRegex.matches(in: responseString, range: NSRange(responseString.startIndex..., in: responseString))
@@ -121,6 +108,7 @@ struct SiteInfo: Codable {
121108
let general: General
122109
let namespaces: [String: Namespace]
123110
let namespacealiases: [NamespaceAlias]
111+
let magicwords: [MagicWord]
124112
}
125113
let query: Query
126114
}
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import Foundation
22

3-
/// **THIS IS NOT PART OF THE MAIN APP - IT'S A COMMAND LINE UTILITY**
4-
3+
/// **THIS IS A COMMAND LINE UTILITY FOR LOCALIZATION**
54
let count = CommandLine.arguments.count
65
guard count > 1 else {
7-
abort()
6+
print("Please provide a path argument.")
7+
exit(1)
88
}
99

1010
let path = CommandLine.arguments[1]
1111

12-
Process.launchedProcess(launchPath: "\(path)/scripts/localization_extract", arguments: [path]).waitUntilExit()
13-
exportLocalizationsFromSourceCode(path)
14-
importLocalizationsFromTWN(path)
12+
print("Extracting localizations from source code...")
13+
let extractProcess = Process.launchedProcess(launchPath: "\(path)/scripts/localization_extract", arguments: [path])
14+
extractProcess.waitUntilExit()
15+
16+
if extractProcess.terminationStatus == 0 {
17+
print("Localizations extracted successfully.")
18+
print("Exporting localizations from source code...")
19+
exportLocalizationsFromSourceCode(path)
20+
print("Importing localizations from TWN...")
21+
importLocalizationsFromTWN(path)
22+
print("Localizations imported successfully.")
23+
} else {
24+
print("Failed to extract localizations from source code.")
25+
exit(1)
26+
}

ContinueReadingWidget/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>7.2.0</string>
20+
<string>7.6.3</string>
2121
<key>CFBundleVersion</key>
2222
<string>0</string>
2323
<key>NSExtension</key>

ContinueReadingWidget/WMFTodayContinueReadingWidgetViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import UIKit
1+
import WMFComponents
22
import NotificationCenter
33
import WMF
44

@@ -131,9 +131,9 @@ class WMFTodayContinueReadingWidgetViewController: ExtensionViewController, NCWi
131131
} else {
132132
self.daysAgoView.isHidden = true
133133
}
134+
let styles = HtmlUtils.Styles(font: WMFFont.for(.headline, compatibleWith: traitCollection), boldFont: WMFFont.for(.boldHeadline, compatibleWith: traitCollection), italicsFont: WMFFont.for(.headline, compatibleWith: traitCollection), boldItalicsFont: WMFFont.for(.boldHeadline, compatibleWith: traitCollection), color: theme.colors.primaryText, linkColor: theme.colors.link, lineSpacing: 1)
134135

135-
self.titleLabel.attributedText = article.displayTitleHTML.byAttributingHTML(with: .headline, matching: traitCollection)
136-
136+
self.titleLabel.attributedText = NSAttributedString.attributedStringFromHtml(article.displayTitleHTML, styles: styles)
137137
let combinedCompletion = {
138138
self.updatePreferredContentSize()
139139
completion(true)
@@ -153,7 +153,7 @@ class WMFTodayContinueReadingWidgetViewController: ExtensionViewController, NCWi
153153
combinedCompletion()
154154
}
155155
}
156-
156+
157157
func updatePreferredContentSize() {
158158
var fitSize = UIView.layoutFittingCompressedSize
159159
fitSize.width = view.bounds.size.width

NotificationServiceExtension/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>7.2.0</string>
20+
<string>7.6.3</string>
2121
<key>CFBundleVersion</key>
2222
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>NSExtension</key>

0 commit comments

Comments
 (0)