Skip to content

Commit

Permalink
Redirect local copy to online copy at launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Erudition committed Sep 18, 2023
1 parent 7e379f3 commit 39b2d2c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
7 changes: 4 additions & 3 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const config: CapacitorConfig = {
appName: 'Minder',
webDir: 'dist',
server: {
allowNavigation: ["erudition.github.io", "localhost"],
url: "https://erudition.github.io/minder-preview/Erudition/Minder/branch/master/",
allowNavigation: ["erudition.github.io", "localhost"], // don't add "localhost" here
// url: "https://localhost/", // default is https://localhost, but setting this to ANYTHING prevent navigation to localhost...
//url: "https://erudition.github.io/minder-preview/Erudition/Minder/branch/master/",
hostname: 'localhost',
androidScheme: 'https',
cleartext: true,
errorPath: "error.html",
//errorPath: "error.html",
},
plugins: {
SplashScreen: {
Expand Down
3 changes: 2 additions & 1 deletion elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ globalLayout model replica innerStuff =
]
, menuItemHref "Test Marvin Sync" "sync-outline" "?sync=marvin"
, menuItemHref "Reload App" "sync-outline" "index.html"
, menuItemHref "Installed branch" "sync-outline" "https://localhost/index.html"
, menuItemHref "Installed branch" "sync-outline" "https://localhost/fallback.html"
, menuItemHref "Redirect" "sync-outline" "https://localhost/"
, menuItemHref "Master branch" "sync-outline" "https://erudition.github.io/minder-preview/Erudition/Minder/branch/master/"
, Ion.Item.item [ Ion.Item.button, HE.onClick ClearPreferences, Ion.Item.detail False ]
[ Ion.Item.label [] [ H.text "Switch Account" ]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"build": "tsc && vite build",
"build-ci": "vite build",
"build-sync": "vite build && cap sync",
"patch-elm": "rm -rf ~/.elm/0.19.1/packages/ && elm make --output=www/elm-gui.js elm/Main.elm && make --directory ./elm-patches && rm -rf elm-stuff"
"patch-elm": "rm -rf ~/.elm/0.19.1/packages/ && elm make --output=www/elm-gui.js elm/Main.elm && make --directory ./elm-patches && rm -rf elm-stuff",
"capacitor:copy:after": "if [ $CAPACITOR_PLATFORM_NAME == 'web' ]; then echo leaving index in place for web. ; else echo replacing index with go-online... && mv android/app/src/main/assets/public/index.html android/app/src/main/assets/public/fallback.html && mv android/app/src/main/assets/public/go-online.html android/app/src/main/assets/public/index.html; fi"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default defineConfig({
//devOptions: {enabled: true},
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
workbox: {
navigateFallbackDenylist: [/.js/],
globPatterns: ['**/*.{css,ico,png,svg}'] // TODO removed js so capacitor plugins can work
//navigateFallbackDenylist: [/.js/],
globPatterns: ['**/*.{html,css,ico,png,svg}'] // TODO removed js so capacitor plugins can work
},
outDir: "../dist", // weird it's not default, it looks for webapp files to cache here
manifest: {
Expand Down
4 changes: 2 additions & 2 deletions www/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function elmStarted(app) {

App.addListener('appStateChange', ({ isActive }) => {
detectDarkMode();
Toast.show({ text: ("App became " + isActive ? "active!" : "inactive."), duration: "short"}).then();
Toast.show({ text: ("App became " + (isActive ? "active!" : "inactive.")), duration: "short"}).then();
});

App.addListener('appUrlOpen', data => {
Expand All @@ -134,7 +134,7 @@ function elmStarted(app) {

console.log('App opened with URL: ' + url);
};

Toast.show({ text: window.location.href, duration: "short"}).then();
try {
attachOrbit(app);
} catch (problemWithOrbit)
Expand Down
11 changes: 11 additions & 0 deletions www/vite-extra-assets/go-online.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Going online...</title>
<meta http-equiv="refresh" content="0;URL='https://erudition.github.io/minder-preview/Erudition/Minder/branch/master/'" />
</head>
<body>
<h1>Going online...</h1>
<a href="https://erudition.github.io/minder-preview/Erudition/Minder/branch/master/">Online</a>
<a href="https://localhost/fallback.html">Local</a>
</body>
</html>

0 comments on commit 39b2d2c

Please sign in to comment.