Compare commits
No commits in common. "2fece1ede485ce23d3b6328e85a1361ed90c6b4b" and "662053e750f393908ecdeb6265964656415ded49" have entirely different histories.
2fece1ede4
...
662053e750
9 changed files with 33 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
notes2
|
notes2
|
||||||
untracked
|
|
||||||
|
|
|
||||||
26
main.go
26
main.go
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v4"
|
const VERSION = "v3"
|
||||||
const CONTEXT_USER = 1
|
const CONTEXT_USER = 1
|
||||||
const SYNC_PAGINATION = 200
|
const SYNC_PAGINATION = 200
|
||||||
|
|
||||||
|
|
@ -129,6 +129,7 @@ func main() { // {{{
|
||||||
}
|
}
|
||||||
|
|
||||||
http.HandleFunc("/", rootHandler)
|
http.HandleFunc("/", rootHandler)
|
||||||
|
http.HandleFunc("/notes2", pageNotes2)
|
||||||
http.HandleFunc("/login", pageLogin)
|
http.HandleFunc("/login", pageLogin)
|
||||||
http.HandleFunc("/sync", pageSync)
|
http.HandleFunc("/sync", pageSync)
|
||||||
http.HandleFunc("/offline", pageOffline)
|
http.HandleFunc("/offline", pageOffline)
|
||||||
|
|
@ -188,13 +189,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
// All URLs not specifically handled are routed to this function.
|
// All URLs not specifically handled are routed to this function.
|
||||||
// Everything going here should be a static resource.
|
// Everything going here should be a static resource.
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
page := NewPage("notes2")
|
http.Redirect(w, r, "/notes2", http.StatusSeeOther)
|
||||||
|
|
||||||
err := Webengine.Render(page, w, r)
|
|
||||||
if err != nil {
|
|
||||||
w.Write([]byte(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,6 +245,15 @@ func pageLogin(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
func pageNotes2(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
|
page := NewPage("notes2")
|
||||||
|
|
||||||
|
err := Webengine.Render(page, w, r)
|
||||||
|
if err != nil {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} // }}}
|
||||||
func pageSync(w http.ResponseWriter, r *http.Request) { // {{{
|
func pageSync(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
page := NewPage("sync")
|
page := NewPage("sync")
|
||||||
|
|
||||||
|
|
@ -276,9 +280,9 @@ func actionSyncFromServer(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Log.Debug("/sync/from_server", "num_nodes", len(nodes), "maxSeq", maxSeq)
|
Log.Debug("/sync/from_server", "num_nodes", len(nodes), "maxSeq", maxSeq)
|
||||||
foo, _ := json.Marshal(nodes)
|
foo, _ := json.Marshal(nodes)
|
||||||
os.WriteFile(fmt.Sprintf("/tmp/nodes-%d.json", offset), foo, 0644)
|
os.WriteFile(fmt.Sprintf("/tmp/nodes-%d.json", offset), foo, 0644)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
j, _ := json.Marshal(struct {
|
j, _ := json.Marshal(struct {
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,7 @@ n2-nodeui {
|
||||||
margin-bottom: 32px;
|
margin-bottom: 32px;
|
||||||
|
|
||||||
&:invalid {
|
&:invalid {
|
||||||
|
background: #f5f5f5;
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ export class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dontPush)
|
if (!dontPush)
|
||||||
history.pushState({ nodeUUID }, '', `/#${nodeUUID}`)
|
history.pushState({ nodeUUID }, '', `/notes2#${nodeUUID}`)
|
||||||
|
|
||||||
const node = nodeStore.node(nodeUUID)
|
const node = nodeStore.node(nodeUUID)
|
||||||
node.reset() // any modifications are discarded.
|
node.reset() // any modifications are discarded.
|
||||||
|
|
@ -249,7 +249,7 @@ class N2Crumb extends CustomHTMLElement {
|
||||||
this.label = label
|
this.label = label
|
||||||
this.uuid = uuid
|
this.uuid = uuid
|
||||||
|
|
||||||
this.elLink.href = `/#${this.uuid}`
|
this.elLink.href = `/notes2#${this.uuid}`
|
||||||
this.elLink.innerText = this.label
|
this.elLink.innerText = this.label
|
||||||
this.elLink.addEventListener('click', () => _mbus.dispatch("GO_TO_NODE", { nodeUUID: this.uuid, dontPush: false, dontExpand: true }))
|
this.elLink.addEventListener('click', () => _mbus.dispatch("GO_TO_NODE", { nodeUUID: this.uuid, dontPush: false, dontExpand: true }))
|
||||||
}// }}}
|
}// }}}
|
||||||
|
|
|
||||||
6
static/js/lib/fullcalendar.min.js
vendored
Normal file
6
static/js/lib/fullcalendar.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -69,7 +69,7 @@ export class Notes2 extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dontPush)
|
if (!dontPush)
|
||||||
history.pushState({ nodeUUID }, '', `/#${nodeUUID}`)
|
history.pushState({ nodeUUID }, '', `/notes2#${nodeUUID}`)
|
||||||
|
|
||||||
// New node is fetched in order to retrieve content and files.
|
// New node is fetched in order to retrieve content and files.
|
||||||
// Such data is unnecessary to transfer for tree/navigational purposes.
|
// Such data is unnecessary to transfer for tree/navigational purposes.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const CACHE_NAME = 'notes2-{{ .VERSION }}'
|
const CACHE_NAME = 'notes2-{{ .VERSION }}'
|
||||||
const CACHED_ASSETS = [
|
const CACHED_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
|
'/notes2',
|
||||||
'/offline',
|
'/offline',
|
||||||
|
|
||||||
'/css/{{ .VERSION }}/main.css',
|
'/css/{{ .VERSION }}/main.css',
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
"node_store": "/js/{{ .VERSION }}/node_store.mjs",
|
"node_store": "/js/{{ .VERSION }}/node_store.mjs",
|
||||||
"node": "/js/{{ .VERSION }}/node.mjs",
|
"node": "/js/{{ .VERSION }}/node.mjs",
|
||||||
"tree": "/js/{{ .VERSION }}/tree.mjs"
|
"tree": "/js/{{ .VERSION }}/tree.mjs"
|
||||||
|
{{/*
|
||||||
|
"session": "/js/{{ .VERSION }}/session.mjs",
|
||||||
|
"ws": "/_js/{{ .VERSION }}/websocket.mjs"
|
||||||
|
*/}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -29,6 +33,8 @@
|
||||||
import { MessageBus } from '/js/{{ .VERSION }}/mbus.mjs'
|
import { MessageBus } from '/js/{{ .VERSION }}/mbus.mjs'
|
||||||
window._mbus = new MessageBus()
|
window._mbus = new MessageBus()
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/sjcl.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/fullcalendar.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">{{ block "page" . }}{{ end }}</div>
|
<div id="app">{{ block "page" . }}{{ end }}</div>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class Login {
|
||||||
const password = document.getElementById('password').value
|
const password = document.getElementById('password').value
|
||||||
API.authenticate(username, password)
|
API.authenticate(username, password)
|
||||||
.then(ans=>{
|
.then(ans=>{
|
||||||
location.href = '/'
|
location.href = '/notes2'
|
||||||
})
|
})
|
||||||
.catch(e=>{
|
.catch(e=>{
|
||||||
setTimeout(()=>this.errorDiv.innerText = e, 75)
|
setTimeout(()=>this.errorDiv.innerText = e, 75)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue