File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33node_modules
44public /*
55main
6- assets
6+ assets /*
7+ ! assets /manifest.json
78database
89mokintoken
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " mokintoken" ,
3+ "icons" : [],
4+ "start_url" : " /" ,
5+ "display" : " standalone" ,
6+ "theme_color" : " #000000" ,
7+ "background_color" : " #ffffff" ,
8+ "serviceworker" : {
9+ "src" : " /assets/service-worker.js"
10+ },
11+ "share_target" : {
12+ "action" : " /assets/share-target/" ,
13+ "method" : " POST" ,
14+ "enctype" : " multipart/form-data" ,
15+ "params" : {
16+ "text" : " text" ,
17+ "files" : [
18+ {
19+ "name" : " img" ,
20+ "accept" : [
21+ " image/*"
22+ ]
23+ }
24+ ]
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ func main() {
249249
250250 http .HandleFunc ("/" , userViews ("home" ))
251251 http .HandleFunc ("/about" , userViews ("about" ))
252+ http .HandleFunc ("/noteSaved" , userViews ("noteSaved" ))
252253 http .HandleFunc ("/decrypt/" , decryptHandler (db ))
253254 http .HandleFunc ("/api/save-note" , saveNoteHandler (db ))
254255 http .HandleFunc ("/ping" , ping (db ))
Original file line number Diff line number Diff line change 99 },
1010 "scripts" : {
1111 "test" : " echo \" Error: no test specified\" && exit 1" ,
12- "build" : " rollup --config && cp node_modules/tachyons/css/tachyons.min.css assets" ,
12+ "build" : " rollup --config && rollup --config rollup-serviceworker.config.js && cp node_modules/tachyons/css/tachyons.min.css assets" ,
1313 "dev" : " rollup --config -w"
1414 },
1515 "author" : " " ,
Original file line number Diff line number Diff line change @@ -8,5 +8,32 @@ async function main() {
88 const { Decrypt } = await import ( './decrypt' )
99 new Decrypt ( )
1010 }
11+
12+ if ( location . pathname . startsWith ( '/noteSaved' ) ) {
13+ const { NoteSaved } = await import ( './noteSaved' )
14+ new NoteSaved ( )
15+ }
1116}
1217main ( )
18+
19+ const registerServiceWorker = async ( ) => {
20+ if ( "serviceWorker" in navigator ) {
21+ try {
22+ const registration = await navigator . serviceWorker . register ( "/assets/service-worker.js" , {
23+ scope : "/assets/" ,
24+ } )
25+ if ( registration . installing ) {
26+ console . log ( "Service worker installing" )
27+ } else if ( registration . waiting ) {
28+ console . log ( "Service worker installed" )
29+ } else if ( registration . active ) {
30+ console . log ( "Service worker active" )
31+ }
32+ } catch ( error ) {
33+ console . error ( `Registration failed with ${ error } ` )
34+ }
35+ }
36+ }
37+
38+ registerServiceWorker ( ) ;
39+
Original file line number Diff line number Diff line change 1+ export class NoteSaved {
2+
3+ constructor ( ) {
4+ console . log ( 'note saved todo' )
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ import nacl from 'tweetnacl'
2+ import naclUutil from 'tweetnacl-util'
3+ import { Base64 } from 'js-base64'
4+
5+ console . log ( "ass" + nacl + naclUutil + Base64 )
6+
7+
8+ self . addEventListener ( "fetch" , ( event ) => {
9+ // Regular requests not related to Web Share Target.
10+ if ( event . request . method !== "POST" || new URL ( event . request . url ) . pathname != "/assets/share-target" ) {
11+ event . respondWith ( fetch ( event . request ) )
12+ return
13+ }
14+
15+ // Requests related to Web Share Target.
16+ event . respondWith (
17+ ( async ( ) => {
18+ const formData = await event . request . formData ( )
19+ // encrypt note or image
20+ // send to fetch api
21+ // respond with saved note page
22+ return Response . redirect ( '/noteSaved#todoshitinthehash' , 303 )
23+ } ) ( ) ,
24+ )
25+ } )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async function getImgBase64(ele) {
1717
1818export class Welcome {
1919 loadNonceAndKey ( ) {
20- window . location . hash = '' // clear out old key
20+ // window.location.hash = '' // clear out old key
2121 // always generate new nonce
2222 const nonce = nacl . randomBytes ( nacl . secretbox . nonceLength )
2323 const key = nacl . randomBytes ( nacl . secretbox . keyLength )
Original file line number Diff line number Diff line change 1+ import commonjs from '@rollup/plugin-commonjs'
2+ import resolve from '@rollup/plugin-node-resolve'
3+ import builtins from 'rollup-plugin-node-builtins'
4+ import globals from 'rollup-plugin-node-globals'
5+ module . exports = {
6+ input : 'resources/js/service-worker.js' ,
7+ output : {
8+ dir : 'assets'
9+ } ,
10+ plugins : [
11+ commonjs ( ) ,
12+ resolve ( {
13+ browser : true ,
14+ preferBuiltins : false
15+ } ) ,
16+ builtins ( ) ,
17+ globals ( )
18+ ]
19+ }
Original file line number Diff line number Diff line change 1+ {{define "content"}}
2+
3+ < main >
4+ < h1 class ="tc f1 pv6 "> NOTE SAVED TODO/h1>
5+ </ main >
6+ {{end}}
You can’t perform that action at this time.
0 commit comments