Skip to content

Commit

Permalink
Test pwas
Browse files Browse the repository at this point in the history
  • Loading branch information
easafe committed Jul 3, 2024
1 parent 251b27d commit 8bcd3cc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
17 changes: 17 additions & 0 deletions file/default/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"theme_color": "#213027",
"start_url": "/im",
"orientation": "any",
"name": "MeroChat - Friendly Random Chat",
"short_name": "MeroChat",
"display": "standalone",
"background_color": "#213027",
"description": "Platonic only, karma based random chat",
"icons": [
{
"src": "/file/default/loading.png",
"sizes": "46x46",
"type": "image/png"
}
]
}
7 changes: 7 additions & 0 deletions file/default/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
self.addEventListener('install', (e) => {
e.waitUntil((async () => {
// let cache = await caches.open(cacheName);

// await cache.addAll(contentToCache);
})());
});
2 changes: 1 addition & 1 deletion src/Server/File.purs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ saveBase64File input =
if DS.member extension allowedExtensions then do
uuid ← R.liftEffect (DU.toString <$> DU.genUUID)
let fileName = uuid <> extension
R.liftAff $ NFA.writeFile (localBasePath <> uploadFolder <> fileName) buffer
R.liftAff $ NFA.writeFile (localBasePath <> uploadFolder <> fileName) buffer
pure fileName
else
invalidImage
Expand Down
3 changes: 2 additions & 1 deletion src/Server/Template.purs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ templateWith parameters@{ title, content, css, bundled, footer, favicon } =
, HE.meta [ HA.name "viewport", HA.content "width=device-width, initial-scale=1.0" ]
, HE.meta [ HA.name "description", HA.content "Chat to new people who also just want to chat. MeroChat is a text based chat site for having actual conversations" ]
, HE.link [ HA.id "favicon", HA.rel "shortcut icon", HA.type' "image/ico", HA.href favicon ]
, HE.link [ HA.rel "manifest", HA.href favicon, HA.href $ SP.resourcePath (Right Manifest) Json ]
, HE.title title
] <> styleSheets
)
Expand All @@ -81,7 +82,7 @@ templateWith parameters@{ title, content, css, bundled, footer, favicon } =
else
[ HE.script' [ HA.type' "text/javascript", HA.src $ SP.bundlePath Common Js ]
]
) <> parameters.javascript
) <> [ HE.script [HA.type' "text/javascript"] "if (`serviceWorker` in navigator) navigator.serviceWorker.register(`/file/default/sw.js`);" ] <> parameters.javascript

externalFooter a. Html a
externalFooter =
Expand Down
6 changes: 5 additions & 1 deletion src/Shared/Resource.purs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bundleFolder = "bundle/"
defaultFolder String
defaultFolder = "default/"

data ResourceType = Css | Js | Png | Ico | Ignore
data ResourceType = Css | Js | Png | Ico | Json | Ignore

derive instance Eq ResourceType

Expand All @@ -57,6 +57,7 @@ data Bundle
| InternalHelp
| Landing
| Feedback
| Manifest
| KarmaPrivileges
| Login
| Profile
Expand Down Expand Up @@ -141,6 +142,7 @@ resourceName = case _ of
Right Profile"profile"
Right Recover"recover"
Right Settings"settings"
Right Manifest"manifest"
Left Logo3Small"logo-3-small"
Left LogoSmall"logo-small"
Left Logo"logo"
Expand Down Expand Up @@ -185,6 +187,7 @@ resourceType = case _ of
Js".bundle.js"
Css".css"
Png".png"
Json".json"
Ico".ico"
Ignore""

Expand All @@ -200,6 +203,7 @@ replacement bundle tp
External → reps ".[external-js-contenthash]" ".[external-css-contenthash]"
Help → reps ".[help-js-contenthash]" ".[help-css-contenthash]"
Im → reps ".[im-js-contenthash]" ".[im-css-contenthash]"
Manifest""
Feedback → reps ".[feedback-js-contenthash]" ".[feedback-css-contenthash]"
InternalHelp → reps ".[internalHelp-js-contenthash]" ".[internalHelp-css-contenthash]"
Landing → reps ".[landing-js-contenthash]" ".[landing-css-contenthash]"
Expand Down

0 comments on commit 8bcd3cc

Please sign in to comment.