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

View file

@ -8,19 +8,22 @@ struct WebReaderContent {
let item: FeedItem
let themeKey: String
let authToken: String
let appEnv: AppEnvironment
init(
htmlContent: String,
item: FeedItem,
authToken: String,
isDark: Bool,
fontSize: Int
fontSize: Int,
appEnv: AppEnvironment
) {
self.textFontSize = fontSize
self.content = htmlContent
self.item = item
self.themeKey = isDark ? "Gray" : "LightGray"
self.authToken = authToken
self.appEnv = appEnv
}
// swiftlint:disable line_length
@ -31,32 +34,33 @@ struct WebReaderContent {
<head>
<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' />
<style>
@import url("fonts.css");
</style>
</head>
<body>
<div id="root">
<script type="text/javascript">
function loadArticle() {
window.omnivoreArticle = {
id: "test",
linkId: "test",
slug: "test-slug",
createdAt: new Date().toISOString(),
savedAt: new Date().toISOString(),
url: "https://example.com",
title: `\(item.title)`,
content: `\(content)`,
originalArticleUrl: "https://example.com",
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
highlights: [],
}
window.omnivoreEnv = {
"NEXT_PUBLIC_APP_ENV": "\(appEnv.rawValue)",
"NEXT_PUBLIC_LOCAL_BASE_URL": "\(appEnv.webAppBaseURL.absoluteString)",
"NEXT_PUBLIC_LOCAL_SERVER_BASE_URL": "\(appEnv.serverBaseURL.absoluteString)",
"NEXT_PUBLIC_LOCAL_HIGHLIGHTS_BASE_URL": "\(appEnv.highlightsServerBaseURL.absoluteString)"
}
window.omnivoreArticle = {
id: "test",
linkId: "test",
slug: "test-slug",
createdAt: new Date().toISOString(),
savedAt: new Date().toISOString(),
url: "https://example.com",
title: `\(item.title)`,
content: `\(content)`,
originalArticleUrl: "https://example.com",
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
highlights: [],
}
loadArticle()
window.fontSize = \(textFontSize)
window.localStorage.setItem("authToken", "\(authToken)")
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 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 {
var graphqlPath: String {
@ -59,4 +63,17 @@ public extension AppEnvironment {
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 enableSnooze = 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');
}