Skip to content

Commit

Permalink
Improved Ecosia's TopSites selection
Browse files Browse the repository at this point in the history
  • Loading branch information
d4r1091 committed May 16, 2024
1 parent 957faf6 commit eacc298
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ class DefaultBundleImageFetcher: BundleImageFetcher {
into the BrowserKit package, this would have resulted into macking a lot of changes into accessors to be able to make our own file outside of the BrowserKit context.
*/

let schemeStrippedFinancialUrlString = Environment.current.urlProvider.financialReports.absoluteString.replacingOccurrences(of: "https://", with: "")
if domain.bundleDomains.contains(schemeStrippedFinancialUrlString) {
return "blog.ecosia.finance"
let financialReportsURL = Environment.current.urlProvider.financialReports.absoluteString.replacingOccurrences(of: "https://", with: "")
let privacyURL = Environment.current.urlProvider.privacy.absoluteString.replacingOccurrences(of: "https://", with: "")
let foo = [financialReportsURL : "blog.ecosia.finance",
privacyURL : "privacy.ecosia"]
if let matchingKey = foo.keys.first(where: { domain.bundleDomains.contains($0) }) {
return foo[matchingKey]
}
return domain.bundleDomains.first(where: { bundledImages[$0] != nil })
}
Expand Down
27 changes: 25 additions & 2 deletions Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
2C1298A52BF5EB16005AE4E4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 2C1298A42BF5EB16005AE4E4 /* PrivacyInfo.xcprivacy */; };
2C1298A62BF5EB1E005AE4E4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 2C1298A42BF5EB16005AE4E4 /* PrivacyInfo.xcprivacy */; };
2C1298A72BF5EB1F005AE4E4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 2C1298A42BF5EB16005AE4E4 /* PrivacyInfo.xcprivacy */; };
2C1298A82BF5EE23005AE4E4 /* libStorage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FCAE21A1ABB51F800877008 /* libStorage.a */; };
2C1298AC2BF5EE3E005AE4E4 /* Core in Frameworks */ = {isa = PBXBuildFile; productRef = 2C1298AB2BF5EE3E005AE4E4 /* Core */; };
2C1298AF2BF602D3005AE4E4 /* DefaultSuggestedSites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 394CF6CE1BAA493C00906917 /* DefaultSuggestedSites.swift */; };
2C1F23BD2B9F405E00186F55 /* Core in Frameworks */ = {isa = PBXBuildFile; productRef = 2C1F23BC2B9F405E00186F55 /* Core */; };
2C4414422BD7B43F00249464 /* BingDistributionExperiment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C4414412BD7B43F00249464 /* BingDistributionExperiment.swift */; };
2C4414452BD7B4D800249464 /* BingDistributionExperimentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C4414432BD7B4D000249464 /* BingDistributionExperimentTests.swift */; };
Expand Down Expand Up @@ -374,7 +377,6 @@
392ED7E61D0AEFEF009D9B62 /* HomePageAccessors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392ED7E51D0AEFEF009D9B62 /* HomePageAccessors.swift */; };
3943A81D1E9807C700D4F6DC /* FxAPushMessageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3943A81C1E9807C700D4F6DC /* FxAPushMessageTest.swift */; };
39455F771FC83F430088A22C /* TabEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39455F761FC83F430088A22C /* TabEventHandler.swift */; };
394CF6CF1BAA493C00906917 /* DefaultSuggestedSites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 394CF6CE1BAA493C00906917 /* DefaultSuggestedSites.swift */; };
3964B09A1EA8F06F00F2EEF4 /* FeatureSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3964B0991EA8F06F00F2EEF4 /* FeatureSwitch.swift */; };
3964B09C1EA8F32C00F2EEF4 /* FeatureSwitchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3964B09B1EA8F32C00F2EEF4 /* FeatureSwitchTests.swift */; };
396CDB55203C5B870034A3A3 /* TabTrayController+KeyCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 396CDB54203C5B870034A3A3 /* TabTrayController+KeyCommands.swift */; };
Expand Down Expand Up @@ -1605,6 +1607,13 @@
remoteGlobalIDString = F84B21BD1A090F8100AAB793;
remoteInfo = Client;
};
2C1298A92BF5EE23005AE4E4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F84B21B61A090F8100AAB793 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 2FCAE2191ABB51F800877008;
remoteInfo = Storage;
};
2F11EE4F1ABCAE910083902D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F84B21B61A090F8100AAB793 /* Project object */;
Expand Down Expand Up @@ -7691,6 +7700,7 @@
C820439A2523DC4500740B71 /* libStorage.a in Frameworks */,
5A70EF12295DFD6400790249 /* Common in Frameworks */,
D09A0CDC1FAA24CC009A0273 /* libAccount.a in Frameworks */,
2C1298AC2BF5EE3E005AE4E4 /* Core in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -7837,6 +7847,7 @@
43BE5827278BE81500491291 /* RustMozillaAppServices.framework in Frameworks */,
5A8FD0EE293A7D6D00333AA7 /* SnapKit in Frameworks */,
C82043AF2523DC9600740B71 /* Sync.framework in Frameworks */,
2C1298A82BF5EE23005AE4E4 /* libStorage.a in Frameworks */,
5A70EF14295DFD7C00790249 /* Common in Frameworks */,
2CF4DA632BB31970001C340A /* Core in Frameworks */,
C877039625222FDC006E38EB /* Shared.framework in Frameworks */,
Expand Down Expand Up @@ -12198,6 +12209,7 @@
packageProductDependencies = (
5A87148B292EA1640039A5BD /* Fuzi */,
5A70EF11295DFD6400790249 /* Common */,
2C1298AB2BF5EE3E005AE4E4 /* Core */,
);
productName = Sync;
productReference = 2827315E1ABC9BE600AA1954 /* Sync.framework */;
Expand Down Expand Up @@ -12510,6 +12522,7 @@
dependencies = (
D09A0CF11FAA2C7E009A0273 /* PBXTargetDependency */,
D09A0CF31FAA2C81009A0273 /* PBXTargetDependency */,
2C1298AA2BF5EE23005AE4E4 /* PBXTargetDependency */,
);
name = ShareTo;
packageProductDependencies = (
Expand Down Expand Up @@ -13307,14 +13320,14 @@
B2999FED2B044A5900F0FEC1 /* UnencryptedCreditCardFields.swift in Sources */,
15DE98FD27FCED4F00F1ECDB /* RustRemoteTabs.swift in Sources */,
285D3B901B4386520035FD22 /* SQLiteQueue.swift in Sources */,
394CF6CF1BAA493C00906917 /* DefaultSuggestedSites.swift in Sources */,
B2999FEF2B044B4E00F0FEC1 /* RustAutofillEncryptionKeys.swift in Sources */,
2FCAE2781ABB531100877008 /* Visit.swift in Sources */,
D3BF8CBB1B7425570007AFE6 /* DiskImageStore.swift in Sources */,
E6FF6ACA1D873CFF0070C294 /* PageMetadata.swift in Sources */,
F8AAC1B429663619000BCDEC /* RustAutofill.swift in Sources */,
45D5EDCE292D83DB00311934 /* SQLitePinnedSites.swift in Sources */,
E18BAB0028E4AEBB00098AE2 /* ImageIdentifiers.swift in Sources */,
2C1298AF2BF602D3005AE4E4 /* DefaultSuggestedSites.swift in Sources */,
45D5EDCC292D839800311934 /* PinnedSites.swift in Sources */,
2FCAE2611ABB531100877008 /* FileAccessor.swift in Sources */,
E677F0451D9423FB00ECF1FB /* SQLiteMetadata.swift in Sources */,
Expand Down Expand Up @@ -14622,6 +14635,11 @@
target = F84B21BD1A090F8100AAB793 /* Client */;
targetProxy = 28ECD9BE1BA1F12B00D829DA /* PBXContainerItemProxy */;
};
2C1298AA2BF5EE23005AE4E4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 2FCAE2191ABB51F800877008 /* Storage */;
targetProxy = 2C1298A92BF5EE23005AE4E4 /* PBXContainerItemProxy */;
};
2F11EE501ABCAE910083902D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 288A2D851AB8B3260023ABC3 /* Shared */;
Expand Down Expand Up @@ -21009,6 +21027,11 @@
isa = XCSwiftPackageProductDependency;
productName = Redux;
};
2C1298AB2BF5EE3E005AE4E4 /* Core */ = {
isa = XCSwiftPackageProductDependency;
package = 2C61887D2B7A89E4006B70D7 /* XCRemoteSwiftPackageReference "ios-core" */;
productName = Core;
};
2C1F23BC2B9F405E00186F55 /* Core */ = {
isa = XCSwiftPackageProductDependency;
package = 2C61887D2B7A89E4006B70D7 /* XCRemoteSwiftPackageReference "ios-core" */;
Expand Down
6 changes: 3 additions & 3 deletions Client/Assets/bundle_sites.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@
"domain": "fr.blog.ecosia.org"
},
{
"title": "info.ecosia",
"url": "https://info.ecosia.org/privacy",
"title": "privacy.ecosia",
"url": "https://www.ecosia.org/privacy",
"image_url": "info-ecosia-org.png",
"background_color": "#fff",
"domain": "info.ecosia.org"
"domain": "www.ecosia.org/privacy"
},
{
"title": "blog.ecosia.finance",
Expand Down
48 changes: 30 additions & 18 deletions Client/Ecosia/UI/EmptyBookmarksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ final class EmptyBookmarksView: UIView, Themeable {
$0.setContentHuggingPriority(.required, for: .horizontal)
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
$0.numberOfLines = 0
$0.textColor = .legacyTheme.ecosia.secondaryText
$0.adjustsFontForContentSizeCategory = true
}

Expand Down Expand Up @@ -257,24 +256,37 @@ final class EmptyBookmarksView: UIView, Themeable {
importBookmarksButton.setTitleColor(.legacyTheme.ecosia.primaryText, for: .normal)
importBookmarksButton.titleLabel?.font = UX.ImportButtonLabelFont
titleLabel.textColor = .legacyTheme.ecosia.primaryText
containerStackView.arrangedSubviews
.compactMap { ($0 as? UIStackView)?.arrangedSubviews }
.reduce([UIView](), { partialResult, subViews in
var finalResult = partialResult
finalResult.append(contentsOf: subViews)
subViews.compactMap { $0 as? UIStackView }.forEach { subStackView in
finalResult.append(contentsOf: subStackView.arrangedSubviews)
}
return finalResult
})
.forEach {
switch $0 {
case let label as UILabel:
label.textColor = .legacyTheme.ecosia.secondaryText
default:
$0.tintColor = .legacyTheme.ecosia.secondaryText
break
applyThemeToSectionsIn(containerStackView)
}

func applyThemeToSectionsIn(_ stackView: UIStackView) {
var finalResult = [UIView]()
var iterateThroughSubviews: ((UIStackView) -> Void)?

iterateThroughSubviews = { stackView in
for subview in stackView.arrangedSubviews {
if let subStackView = subview as? UIStackView {
iterateThroughSubviews?(subStackView)
} else {
finalResult.append(subview)
}
}
}

stackView.arrangedSubviews.forEach {
if let stackView = $0 as? UIStackView {
iterateThroughSubviews?(stackView)
}
}

finalResult.forEach {
switch $0 {
case let label as UILabel:
label.textColor = .legacyTheme.ecosia.secondaryText
default:
$0.tintColor = .legacyTheme.ecosia.secondaryText
break
}
}
}
}
2 changes: 1 addition & 1 deletion Client/Ecosia/UI/MultiplyImpact/MultiplyImpact.swift
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ final class MultiplyImpact: UIViewController, Themeable {
navigationItem.standardAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
navigationController?.navigationBar.backgroundColor = .legacyTheme.ecosia.modalHeader
navigationController?.navigationBar.tintColor = UIColor.Dark.Text.primary
navigationController?.navigationBar.tintColor = themeManager.currentTheme.type == .light ? UIColor.Dark.Text.primary : .legacyTheme.ecosia.primaryBrand
}

private func updateInviteLink() {
Expand Down
1 change: 1 addition & 0 deletions Client/Frontend/Library/Bookmarks/BookmarksPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ extension BookmarksPanel {
self?.moreButton.isEnabled = true
}
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
alert.view.tintColor = UIColor.legacyTheme.ecosia.primaryButton
alert.popoverPresentationController?.barButtonItem = moreButton
[importAction, exportAction, cancelAction].forEach(alert.addAction)
present(alert, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ extension BookmarksPanelViewModel {
self.onImportDoneHandler = onDone
let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.html"], in: .open)
documentPicker.allowsMultipleSelection = false
// Ecosia: Themeing
documentPicker.view.tintColor = UIColor.legacyTheme.ecosia.primaryButton
documentPicker.delegate = self
viewController.present(documentPicker, animated: true)
}
Expand Down
1 change: 0 additions & 1 deletion Providers/TopSitesProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ private extension TopSitesProviderImplementation {
// Fetch the default sites
let defaultSites = defaultTopSites(prefs)
// Create PinnedSite objects. Used by the view layer to tell topsites apart
let pinnedSites: [Site] = pinnedSites.map({ PinnedSite(site: $0) })
// Ecosia: No need of Pinned Sites
// let pinnedSites: [Site] = pinnedSites.map({ PinnedSite(site: $0) })
// Merge default topsites with a user's topsites.
Expand Down
30 changes: 30 additions & 0 deletions Storage/DefaultSuggestedSites.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Foundation

open class DefaultSuggestedSites {
/* Ecosia: Replace Default Suggested Sites
public static let urlMap = [
"https://www.amazon.com/": [
"as": "https://www.amazon.in",
Expand Down Expand Up @@ -132,4 +133,33 @@ open class DefaultSuggestedSites {
)
]
]
*/
public static let sites = [
"default": [
SuggestedSiteData(
url: Environment.current.urlProvider.financialReports.absoluteString,
bgColor: "0x000000",
imageUrl: "asset://suggestedsites_ecosia-org",
faviconUrl: "asset://defaultFavicon",
trackingId: 0,
title: NSLocalizedString("Financial reports", tableName: "Ecosia", comment: "")
),
SuggestedSiteData(
url: Environment.current.urlProvider.privacy.absoluteString,
bgColor: "0x000000",
imageUrl: "asset://suggestedsites_ecosia-org",
faviconUrl: "asset://defaultFavicon",
trackingId: 0,
title: NSLocalizedString("Privacy", tableName: "Ecosia", comment: "")
),
SuggestedSiteData(
url: Environment.current.urlProvider.blog.absoluteString,
bgColor: "0x000000",
imageUrl: "asset://suggestedsites_ecosia-org",
faviconUrl: "asset://defaultFavicon",
trackingId: 0,
title: NSLocalizedString("Trees update", tableName: "Ecosia", comment: "")
)
]
]
}
37 changes: 0 additions & 37 deletions Storage/EcosiaDefaultSuggestedSites.swift

This file was deleted.

0 comments on commit eacc298

Please sign in to comment.