set wedreader server addresses

This commit is contained in:
Satindar Dhillon
2022-03-21 13:15:03 -07:00
parent 65f664c064
commit ebd7018a14
5 changed files with 48 additions and 108 deletions

View File

@ -169,6 +169,7 @@ struct WebReaderContainerView: View {
navBarVisibilityRatio = $0 navBarVisibilityRatio = $0
}, },
authToken: authenticator.authToken ?? "", authToken: authenticator.authToken ?? "",
appEnv: dataService.appEnvironment,
increaseFontActionID: $increaseFontActionID, increaseFontActionID: $increaseFontActionID,
decreaseFontActionID: $decreaseFontActionID, decreaseFontActionID: $decreaseFontActionID,
annotationSaveTransactionID: nil annotationSaveTransactionID: nil
@ -249,6 +250,7 @@ struct WebReader: UIViewRepresentable {
let webViewActionHandler: (WKScriptMessage) -> Void let webViewActionHandler: (WKScriptMessage) -> Void
let navBarVisibilityRatioUpdater: (Double) -> Void let navBarVisibilityRatioUpdater: (Double) -> Void
let authToken: String let authToken: String
let appEnv: AppEnvironment
@Binding var increaseFontActionID: UUID? @Binding var increaseFontActionID: UUID?
@Binding var decreaseFontActionID: UUID? @Binding var decreaseFontActionID: UUID?
@ -275,7 +277,8 @@ struct WebReader: UIViewRepresentable {
item: item, item: item,
authToken: authToken, authToken: authToken,
isDark: UITraitCollection.current.userInterfaceStyle == .dark, isDark: UITraitCollection.current.userInterfaceStyle == .dark,
fontSize: fontSize() fontSize: fontSize(),
appEnv: appEnv
) )
.styledContent, .styledContent,
baseURL: ViewsPackage.bundleURL baseURL: ViewsPackage.bundleURL

View File

@ -8,19 +8,22 @@ struct WebReaderContent {
let item: FeedItem let item: FeedItem
let themeKey: String let themeKey: String
let authToken: String let authToken: String
let appEnv: AppEnvironment
init( init(
htmlContent: String, htmlContent: String,
item: FeedItem, item: FeedItem,
authToken: String, authToken: String,
isDark: Bool, isDark: Bool,
fontSize: Int fontSize: Int,
appEnv: AppEnvironment
) { ) {
self.textFontSize = fontSize self.textFontSize = fontSize
self.content = htmlContent self.content = htmlContent
self.item = item self.item = item
self.themeKey = isDark ? "Gray" : "LightGray" self.themeKey = isDark ? "Gray" : "LightGray"
self.authToken = authToken self.authToken = authToken
self.appEnv = appEnv
} }
// swiftlint:disable line_length // swiftlint:disable line_length
@ -31,32 +34,33 @@ struct WebReaderContent {
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no' /> <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no' />
<style>
@import url("fonts.css");
</style>
</head> </head>
<body> <body>
<div id="root"> <div id="root">
<script type="text/javascript"> <script type="text/javascript">
function loadArticle() { window.omnivoreEnv = {
window.omnivoreArticle = { "NEXT_PUBLIC_APP_ENV": "\(appEnv.rawValue)",
id: "test", "NEXT_PUBLIC_LOCAL_BASE_URL": "\(appEnv.webAppBaseURL.absoluteString)",
linkId: "test", "NEXT_PUBLIC_LOCAL_SERVER_BASE_URL": "\(appEnv.serverBaseURL.absoluteString)",
slug: "test-slug", "NEXT_PUBLIC_LOCAL_HIGHLIGHTS_BASE_URL": "\(appEnv.highlightsServerBaseURL.absoluteString)"
createdAt: new Date().toISOString(), }
savedAt: new Date().toISOString(),
url: "https://example.com", window.omnivoreArticle = {
title: `\(item.title)`, id: "test",
content: `\(content)`, linkId: "test",
originalArticleUrl: "https://example.com", slug: "test-slug",
contentReader: "WEB", createdAt: new Date().toISOString(),
readingProgressPercent: \(item.readingProgress), savedAt: new Date().toISOString(),
readingProgressAnchorIndex: \(item.readingProgressAnchor), url: "https://example.com",
highlights: [], title: `\(item.title)`,
} content: `\(content)`,
originalArticleUrl: "https://example.com",
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
highlights: [],
} }
loadArticle()
window.fontSize = \(textFontSize) window.fontSize = \(textFontSize)
window.localStorage.setItem("authToken", "\(authToken)") window.localStorage.setItem("authToken", "\(authToken)")
window.localStorage.setItem("theme", "\(themeKey)") window.localStorage.setItem("theme", "\(themeKey)")

View File

@ -27,7 +27,11 @@ private let prodBaseURL = "https://api-prod.omnivore.app"
private let devWebURL = "https://web-dev.omnivore.app" private let devWebURL = "https://web-dev.omnivore.app"
private let demoWebURL = "https://demo.omnivore.app" private let demoWebURL = "https://demo.omnivore.app"
private let prodWebURL = "https://web-prod.omnivore.app" private let prodWebURL = "https://omnivore.app"
private let devHighlightsServerURL = "https://highlights-dev.omnivore.app"
private let demoHighlightsServerURL = "https://highlights-demo.omnivore.app"
private let prodHighlightsServerURL = "https://highlights.omnivore.app"
public extension AppEnvironment { public extension AppEnvironment {
var graphqlPath: String { var graphqlPath: String {
@ -59,4 +63,17 @@ public extension AppEnvironment {
return URL(string: "http://localhost:3000")! return URL(string: "http://localhost:3000")!
} }
} }
var highlightsServerBaseURL: URL {
switch self {
case .dev:
return URL(string: devHighlightsServerURL)!
case .demo:
return URL(string: demoHighlightsServerURL)!
case .prod:
return URL(string: prodHighlightsServerURL)!
case .test, .local:
return URL(string: "http://localhost:8080")!
}
}
} }

View File

@ -15,5 +15,5 @@ public enum FeatureFlag {
public static let enableShareButton = false public static let enableShareButton = false
public static let enableSnooze = false public static let enableSnooze = false
public static let showFeedItemTags = false public static let showFeedItemTags = false
public static let useLocalWebView = false public static let useLocalWebView = true
} }

View File

@ -1,84 +0,0 @@
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.6;
font-size: 18px;
}
.disable-webkit-callout {
-webkit-touch-callout: none;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
@font-face {
font-family: 'Inter';
font-weight: 200;
font-style: normal;
src: url('Inter-ExtraLight.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 300;
font-style: normal;
src: url('Inter-Light.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 400;
font-style: normal;
src: url('Inter-Regular.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 500;
font-style: normal;
src: url('Inter-Medium.ttf');
}
@font-face {
font-family: 'SF Mono';
font-weight: 400;
font-style: normal;
src: url('SFMonoRegular.otf');
}
@font-face {
font-family: 'Inter';
font-weight: 600;
font-style: normal;
src: url('Inter-SemiBold.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 700;
font-style: normal;
src: url('Inter-Bold.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 800;
font-style: normal;
src: url('Inter-ExtraBold.ttf');
}
@font-face {
font-family: 'Inter';
font-weight: 900;
font-style: normal;
src: url('Inter-Black.ttf');
}