Compare commits
82 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60f20a754f | ||
|
|
c132f495b4 | ||
|
|
bcce516c66 | ||
|
|
e9967ebdc6 | ||
|
|
0a6eaed89f | ||
|
|
1a9d532d02 | ||
| d9fa6fd477 | |||
|
|
8039dfaf42 | ||
|
|
0dcc1e1fd9 | ||
|
|
9d45d87ef3 | ||
|
|
2c16d7af60 | ||
|
|
b0496c8de1 | ||
|
|
3b8c6432b6 | ||
|
|
d186489f28 | ||
|
|
6a757c94b0 | ||
|
|
3669b7e6ec | ||
|
|
566cff5e94 | ||
|
|
83e1ce5ffe | ||
|
|
48c1227d9f | ||
|
|
49fd943110 | ||
|
|
f9f083367e | ||
|
|
eea0b1c0f6 | ||
|
|
90b73edc34 | ||
|
|
6782362af1 | ||
|
|
c352176417 | ||
|
|
d89d63803f | ||
|
|
27e493945a | ||
|
|
aee1c25f54 | ||
|
|
7de9feea58 | ||
|
|
a6c94ac7ca | ||
|
|
afcadc8ae1 | ||
|
|
c2555a1d35 | ||
|
|
e9ce21133a | ||
|
|
fd01e751e2 | ||
|
|
08f2344ef9 | ||
|
|
44f5d92815 | ||
|
|
d0f410323e | ||
|
|
dc2b6dac8b | ||
|
|
f98a6ab863 | ||
|
|
5c27f9ed1c | ||
|
|
d3bc5e3f7f | ||
|
|
8768ab1692 | ||
|
|
a3155c5882 | ||
|
|
60c6d4eaba | ||
|
|
51502bd694 | ||
|
|
39c26f77bc | ||
|
|
02c427da23 | ||
|
|
1e42be3a4b | ||
|
|
12a908cde8 | ||
|
|
c6c7e1d23d | ||
|
|
9bb203066c | ||
|
|
9bd4833e4b | ||
|
|
e94ba7a3a9 | ||
|
|
ddb49bad13 | ||
|
|
7031c0100e | ||
|
|
b05e24ce42 | ||
|
|
afa113b8b7 | ||
|
|
52fba2289e | ||
|
|
abbd320b93 | ||
|
|
251186389d | ||
|
|
6cb4833dbd | ||
|
|
aef8f1a572 | ||
|
|
392aff5956 | ||
|
|
ac58fa0fc8 | ||
|
|
48e07c15d4 | ||
|
|
832678ba73 | ||
|
|
d060b0595d | ||
|
|
b35bb30631 | ||
|
|
1a49884a3a | ||
|
|
26fc15b65c | ||
|
|
63a7370570 | ||
|
|
db33be9a37 | ||
|
|
48252de9f3 | ||
|
|
54a0ee4f29 | ||
|
|
9681bd26d5 | ||
|
|
88743898fe | ||
|
|
1389225b45 | ||
|
|
83336cf0fa | ||
|
|
c58a1b988b | ||
|
|
57180e986e | ||
|
|
b7c5a91c06 | ||
|
|
cc9c1ca82e |
40
README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Run from scratch
|
||||
|
||||
## Database
|
||||
|
||||
Create an empty database. The configured user needs to be able to create and alter stuff.
|
||||
|
||||
## Configuration
|
||||
Create a configuration file `$HOME/.config/notes.yaml` with the following content:
|
||||
|
||||
```yaml
|
||||
network:
|
||||
address: '[::]'
|
||||
port: 1371
|
||||
|
||||
websocket:
|
||||
domains:
|
||||
- notes.com
|
||||
|
||||
database:
|
||||
host: 127.0.0.1
|
||||
port: 5432
|
||||
name: notes.com
|
||||
username: notes
|
||||
password: SomePassword
|
||||
|
||||
application:
|
||||
directories:
|
||||
static: /usr/local/share/notes
|
||||
upload: /usr/local/lib/notes/upload
|
||||
|
||||
session:
|
||||
daysvalid: 31
|
||||
```
|
||||
|
||||
## User
|
||||
|
||||
Create a user by running
|
||||
```
|
||||
notes --createuser
|
||||
```
|
||||
13
TODO
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
* Fix dynamic tree updates when adding a new node
|
||||
* Create new admin user when no user exists
|
||||
* File deletion
|
||||
- per file
|
||||
- when deleting node and child nodes
|
||||
* Move node
|
||||
|
||||
|
||||
Long term
|
||||
=========
|
||||
* Load tree iteratively when needed
|
||||
* Notification of timestamps
|
||||
* Journal with quick insert of date and time
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
// Standard
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ type Config struct {
|
|||
Static string
|
||||
Upload string
|
||||
}
|
||||
NotificationBaseURL string
|
||||
}
|
||||
|
||||
Session struct {
|
||||
|
|
@ -37,7 +38,7 @@ type Config struct {
|
|||
|
||||
func ConfigRead(filename string) (config Config, err error) {
|
||||
var rawConfigData []byte
|
||||
rawConfigData, err = ioutil.ReadFile(filename)
|
||||
rawConfigData, err = os.ReadFile(filename)
|
||||
if err != nil { return }
|
||||
|
||||
err = yaml.Unmarshal(rawConfigData, &config)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/gorilla/websocket"
|
||||
|
||||
// Standard
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
@ -72,7 +71,7 @@ func (cm *ConnectionManager) NewConnection(w http.ResponseWriter, r *http.Reques
|
|||
cm.connections[wsConn.UUID] = &wsConn
|
||||
|
||||
// Successfully upgraded to a websocket connection.
|
||||
log.Printf("[%s] Connection from %s", wsConn.UUID, r.RemoteAddr)
|
||||
logger.Info("websocket", "uuid", wsConn.UUID, "remote_addr", r.RemoteAddr)
|
||||
|
||||
go cm.ReadLoop(&wsConn)
|
||||
|
||||
|
|
@ -82,9 +81,7 @@ func (cm *ConnectionManager) NewConnection(w http.ResponseWriter, r *http.Reques
|
|||
// Prune closes an deletes connections. If this happened to be non-fatal, the
|
||||
// user will just have to reconnect.
|
||||
func (cm *ConnectionManager) Prune(wsConn *WsConnection, err error) {// {{{
|
||||
if false {
|
||||
log.Printf("[%s] pruning connection [%s]\n", wsConn.UUID, err)
|
||||
}
|
||||
logger.Info("websocket", "op", "prune", "uuid", wsConn.UUID)
|
||||
wsConn.Conn.Close()
|
||||
wsConn.Pruned = true
|
||||
delete(cm.connections, wsConn.UUID)
|
||||
|
|
@ -98,8 +95,7 @@ func (cm *ConnectionManager) ReadLoop(wsConn *WsConnection) {// {{{
|
|||
break
|
||||
}
|
||||
|
||||
log.Printf("%s\n", data)
|
||||
|
||||
logger.Debug("websocket", "op", "read", "data", data)
|
||||
//cm.Send(wsConn, response)
|
||||
}
|
||||
}// }}}
|
||||
|
|
|
|||
134
db.go
|
|
@ -1,133 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
// Standard
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
var (
|
||||
dbConn string
|
||||
db *sqlx.DB
|
||||
|
||||
//go:embed sql/*
|
||||
embedded embed.FS
|
||||
)
|
||||
|
||||
func dbInit() (err error) {// {{{
|
||||
dbConn = fmt.Sprintf(
|
||||
"host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
|
||||
config.Database.Host,
|
||||
config.Database.Port,
|
||||
config.Database.Username,
|
||||
config.Database.Password,
|
||||
config.Database.Name,
|
||||
)
|
||||
|
||||
log.Printf(
|
||||
"\x1b[32mNotes\x1b[0m Connecting to database %s:%d\n",
|
||||
config.Database.Host,
|
||||
config.Database.Port,
|
||||
)
|
||||
|
||||
if db, err = sqlx.Connect("postgres", dbConn); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = dbVerifyInternals(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = dbUpdate()
|
||||
return
|
||||
}// }}}
|
||||
func dbVerifyInternals() (err error) {// {{{
|
||||
var rows *sqlx.Rows
|
||||
if rows, err = db.Queryx(
|
||||
`SELECT EXISTS (
|
||||
SELECT FROM pg_catalog.pg_class c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE n.nspname = '_internal'
|
||||
AND c.relname = 'db'
|
||||
)`,
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
var exists bool
|
||||
rows.Next()
|
||||
if err = rows.Scan(&exists); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !exists {
|
||||
log.Printf("\x1b[32mNotes\x1b[0m Creating _internal.db\n")
|
||||
if _, err = db.Exec(`
|
||||
CREATE SCHEMA "_internal";
|
||||
|
||||
CREATE TABLE "_internal".db (
|
||||
"key" varchar NOT NULL,
|
||||
value varchar NULL,
|
||||
CONSTRAINT db_pk PRIMARY KEY (key)
|
||||
);
|
||||
|
||||
INSERT INTO _internal.db("key", "value")
|
||||
VALUES('schema', '0');
|
||||
`,
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}// }}}
|
||||
func dbUpdate() (err error) {// {{{
|
||||
/* Current schema revision is read from database.
|
||||
* Used to iterate through the embedded SQL updates
|
||||
* up to the DB_SCHEMA version currently compiled
|
||||
* program is made for. */
|
||||
var rows *sqlx.Rows
|
||||
var schemaStr string
|
||||
var schema int
|
||||
rows, err = db.Queryx(`SELECT value FROM _internal.db WHERE "key"='schema'`)
|
||||
if err != nil { return }
|
||||
defer rows.Close()
|
||||
|
||||
if !rows.Next() {
|
||||
return errors.New("Table _interval.db missing schema row")
|
||||
}
|
||||
|
||||
if err = rows.Scan(&schemaStr); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Run updates
|
||||
schema, err = strconv.Atoi(schemaStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := (schema+1); i <= DB_SCHEMA; i++ {
|
||||
log.Printf("\x1b[32mNotes\x1b[0m Upgrading SQL schema to revision %d\n", i)
|
||||
sql, _ := embedded.ReadFile(
|
||||
fmt.Sprintf("sql/%04d.sql", i),
|
||||
)
|
||||
_, err = db.Exec(string(sql))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = db.Exec(`UPDATE _internal.db SET "value"=$1 WHERE "key"='schema'`, i)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
// Queryable can take both a Db and a transaction
|
||||
type Queryable interface {
|
||||
Exec(string, ...any) (sql.Result, error)
|
||||
Query(string, ...any) (*sql.Rows, error)
|
||||
QueryRow(string, ...any) *sql.Row
|
||||
}
|
||||
|
|
|
|||
14
file.go
|
|
@ -5,7 +5,6 @@ import (
|
|||
"github.com/jmoiron/sqlx"
|
||||
|
||||
// Standard
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -20,11 +19,11 @@ type File struct {
|
|||
Uploaded time.Time
|
||||
}
|
||||
|
||||
func (session Session) AddFile(file *File) (err error) { // {{{
|
||||
file.UserID = session.UserID
|
||||
func AddFile(userID int, file *File) (err error) { // {{{
|
||||
file.UserID = userID
|
||||
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
INSERT INTO file(user_id, node_id, filename, size, mime, md5)
|
||||
VALUES($1, $2, $3, $4, $5, $6)
|
||||
RETURNING id
|
||||
|
|
@ -43,12 +42,11 @@ func (session Session) AddFile(file *File) (err error) { // {{{
|
|||
|
||||
rows.Next()
|
||||
err = rows.Scan(&file.ID)
|
||||
fmt.Printf("%#v\n", file)
|
||||
return
|
||||
} // }}}
|
||||
func (session Session) Files(nodeID, fileID int) (files []File, err error) { // {{{
|
||||
func Files(userID, nodeID, fileID int) (files []File, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(
|
||||
rows, err = service.Db.Conn.Queryx(
|
||||
`SELECT *
|
||||
FROM file
|
||||
WHERE
|
||||
|
|
@ -58,7 +56,7 @@ func (session Session) Files(nodeID, fileID int) (files []File, err error) { //
|
|||
WHEN 0 THEN true
|
||||
ELSE id = $3
|
||||
END`,
|
||||
session.UserID,
|
||||
userID,
|
||||
nodeID,
|
||||
fileID,
|
||||
)
|
||||
|
|
|
|||
12
go.mod
|
|
@ -1,11 +1,17 @@
|
|||
module notes
|
||||
|
||||
go 1.20
|
||||
go 1.21.0
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.3.0
|
||||
git.gibonuddevalla.se/go/webservice v0.2.2
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.3
|
||||
github.com/google/uuid v1.5.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/lib/pq v1.10.9
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
git.gibonuddevalla.se/go/dbschema v1.3.0 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
)
|
||||
|
|
|
|||
10
go.sum
|
|
@ -1,7 +1,13 @@
|
|||
git.gibonuddevalla.se/go/dbschema v1.3.0 h1:HzFMR29tWfy/ibIjltTbIMI4inVktj/rh8bESALibgM=
|
||||
git.gibonuddevalla.se/go/dbschema v1.3.0/go.mod h1:BNw3q/574nXbGoeWyK+tLhRfggVkw2j2aXZzrBKC3ig=
|
||||
git.gibonuddevalla.se/go/webservice v0.2.2 h1:pmfeLa7c9pSPbuu6TuzcJ6yuVwdMLJ8SSPm1IkusThk=
|
||||
git.gibonuddevalla.se/go/webservice v0.2.2/go.mod h1:3uBS6nLbK9qbuGzDls8MZD5Xr9ORY1Srbj6v06BIhws=
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.3 h1:pdIy3/daSY3zMmUr9PXW6ffIt8iYonOv64mgJBpKz+0=
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.3/go.mod h1:j4w320Hk1wvhOPjUaK4GgLvmtnjUUM5yVu6JFO1OCSc=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
|
||||
|
|
|
|||
22
key.go
|
|
@ -3,8 +3,6 @@ package main
|
|||
import (
|
||||
// External
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
// Standard
|
||||
)
|
||||
|
||||
type Key struct {
|
||||
|
|
@ -14,9 +12,9 @@ type Key struct {
|
|||
Key string
|
||||
}
|
||||
|
||||
func (session Session) Keys() (keys []Key, err error) {// {{{
|
||||
func Keys(userID int) (keys []Key, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
if rows, err = db.Queryx(`SELECT * FROM crypto_key WHERE user_id=$1`, session.UserID); err != nil {
|
||||
if rows, err = service.Db.Conn.Queryx(`SELECT * FROM crypto_key WHERE user_id=$1`, userID); err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
|
@ -31,14 +29,14 @@ func (session Session) Keys() (keys []Key, err error) {// {{{
|
|||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) KeyCreate(description, keyEncoded string) (key Key, err error) {// {{{
|
||||
} // }}}
|
||||
func KeyCreate(userID int, description, keyEncoded string) (key Key, err error) { // {{{
|
||||
var row *sqlx.Rows
|
||||
if row, err = db.Queryx(
|
||||
if row, err = service.Db.Conn.Queryx(
|
||||
`INSERT INTO crypto_key(user_id, description, key)
|
||||
VALUES($1, $2, $3)
|
||||
RETURNING *`,
|
||||
session.UserID,
|
||||
userID,
|
||||
description,
|
||||
keyEncoded,
|
||||
); err != nil {
|
||||
|
|
@ -54,10 +52,10 @@ func (session Session) KeyCreate(description, keyEncoded string) (key Key, err e
|
|||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) KeyCounter() (counter int64, err error) {// {{{
|
||||
} // }}}
|
||||
func KeyCounter() (counter int64, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`SELECT nextval('aes_ccm_counter') AS counter`)
|
||||
rows, err = service.Db.Conn.Queryx(`SELECT nextval('aes_ccm_counter') AS counter`)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -66,6 +64,6 @@ func (session Session) KeyCounter() (counter int64, err error) {// {{{
|
|||
rows.Next()
|
||||
err = rows.Scan(&counter)
|
||||
return
|
||||
}// }}}
|
||||
} // }}}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
|
|
|||
580
node.go
|
|
@ -3,11 +3,29 @@ package main
|
|||
import (
|
||||
// External
|
||||
"github.com/jmoiron/sqlx"
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"time"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type ChecklistItem struct {
|
||||
ID int
|
||||
GroupID int `db:"checklist_group_id"`
|
||||
Order int
|
||||
Label string
|
||||
Checked bool
|
||||
}
|
||||
|
||||
type ChecklistGroup struct {
|
||||
ID int
|
||||
NodeID int `db:"node_id"`
|
||||
Order int
|
||||
Label string
|
||||
Items []ChecklistItem
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
ID int
|
||||
UserID int `db:"user_id"`
|
||||
|
|
@ -21,11 +39,16 @@ type Node struct {
|
|||
Files []File
|
||||
Complete bool
|
||||
Level int
|
||||
|
||||
ChecklistGroups []ChecklistGroup
|
||||
|
||||
ContentEncrypted string `db:"content_encrypted" json:"-"`
|
||||
Markdown bool
|
||||
}
|
||||
|
||||
func (session Session) NodeTree(startNodeID int) (nodes []Node, err error) {// {{{
|
||||
func NodeTree(userID, startNodeID int) (nodes []Node, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
WITH RECURSIVE nodetree AS (
|
||||
SELECT
|
||||
*,
|
||||
|
|
@ -60,7 +83,7 @@ func (session Session) NodeTree(startNodeID int) (nodes []Node, err error) {// {
|
|||
ORDER BY
|
||||
path ASC
|
||||
`,
|
||||
session.UserID,
|
||||
userID,
|
||||
startNodeID,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -77,6 +100,9 @@ func (session Session) NodeTree(startNodeID int) (nodes []Node, err error) {// {
|
|||
for rows.Next() {
|
||||
node := Node{}
|
||||
node.Complete = false
|
||||
node.Crumbs = []Node{}
|
||||
node.Children = []Node{}
|
||||
node.Files = []File{}
|
||||
if err = rows.StructScan(&node); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -84,10 +110,10 @@ func (session Session) NodeTree(startNodeID int) (nodes []Node, err error) {// {
|
|||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) RootNode() (node Node, err error) {// {{{
|
||||
} // }}}
|
||||
func RootNode(userID int) (node Node, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
|
|
@ -98,7 +124,7 @@ func (session Session) RootNode() (node Node, err error) {// {{{
|
|||
user_id = $1 AND
|
||||
parent_id IS NULL
|
||||
`,
|
||||
session.UserID,
|
||||
userID,
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -106,11 +132,11 @@ func (session Session) RootNode() (node Node, err error) {// {{{
|
|||
defer rows.Close()
|
||||
|
||||
node.Name = "Start"
|
||||
node.UserID = session.UserID
|
||||
node.UserID = userID
|
||||
node.Complete = true
|
||||
node.Children = []Node{}
|
||||
node.Crumbs = []Node{}
|
||||
node.Files = []File{}
|
||||
node.Crumbs = []Node{}
|
||||
node.Files = []File{}
|
||||
for rows.Next() {
|
||||
row := Node{}
|
||||
if err = rows.StructScan(&row); err != nil {
|
||||
|
|
@ -126,14 +152,14 @@ func (session Session) RootNode() (node Node, err error) {// {{{
|
|||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
||||
} // }}}
|
||||
func RetrieveNode(userID, nodeID int) (node Node, err error) { // {{{
|
||||
if nodeID == 0 {
|
||||
return session.RootNode()
|
||||
return RootNode(userID)
|
||||
}
|
||||
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
WITH RECURSIVE recurse AS (
|
||||
SELECT
|
||||
id,
|
||||
|
|
@ -142,6 +168,8 @@ func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
|||
COALESCE(crypto_key_id, 0) AS crypto_key_id,
|
||||
name,
|
||||
content,
|
||||
content_encrypted,
|
||||
markdown,
|
||||
0 AS level
|
||||
FROM node
|
||||
WHERE
|
||||
|
|
@ -157,6 +185,8 @@ func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
|||
COALESCE(n.crypto_key_id, 0) AS crypto_key_id,
|
||||
n.name,
|
||||
'' AS content,
|
||||
'' AS content_encrypted,
|
||||
false AS markdown,
|
||||
r.level + 1 AS level
|
||||
FROM node n
|
||||
INNER JOIN recurse r ON n.parent_id = r.id AND r.level = 0
|
||||
|
|
@ -166,7 +196,7 @@ func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
|||
|
||||
SELECT * FROM recurse ORDER BY level ASC
|
||||
`,
|
||||
session.UserID,
|
||||
userID,
|
||||
nodeID,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -188,13 +218,21 @@ func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
|||
}
|
||||
|
||||
if row.Level == 0 {
|
||||
node.ID = row.ID
|
||||
node.UserID = row.UserID
|
||||
node.ParentID = row.ParentID
|
||||
node.ID = row.ID
|
||||
node.UserID = row.UserID
|
||||
node.ParentID = row.ParentID
|
||||
node.CryptoKeyID = row.CryptoKeyID
|
||||
node.Name = row.Name
|
||||
node.Content = row.Content
|
||||
node.Complete = true
|
||||
node.Name = row.Name
|
||||
node.Complete = true
|
||||
node.Markdown = row.Markdown
|
||||
|
||||
if node.CryptoKeyID > 0 {
|
||||
node.Content = row.ContentEncrypted
|
||||
} else {
|
||||
node.Content = row.Content
|
||||
}
|
||||
|
||||
node.retrieveChecklist()
|
||||
}
|
||||
|
||||
if row.Level == 1 {
|
||||
|
|
@ -208,14 +246,14 @@ func (session Session) Node(nodeID int) (node Node, err error) {// {{{
|
|||
}
|
||||
}
|
||||
|
||||
node.Crumbs, err = session.NodeCrumbs(node.ID)
|
||||
node.Files, err = session.Files(node.ID, 0)
|
||||
node.Crumbs, err = NodeCrumbs(node.ID)
|
||||
node.Files, err = Files(userID, node.ID, 0)
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) NodeCrumbs(nodeID int) (nodes []Node, err error) {// {{{
|
||||
} // }}}
|
||||
func NodeCrumbs(nodeID int) (nodes []Node, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
WITH RECURSIVE nodes AS (
|
||||
SELECT
|
||||
id,
|
||||
|
|
@ -240,7 +278,7 @@ func (session Session) NodeCrumbs(nodeID int) (nodes []Node, err error) {// {{{
|
|||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
|
||||
nodes = []Node{}
|
||||
for rows.Next() {
|
||||
node := Node{}
|
||||
|
|
@ -250,11 +288,11 @@ func (session Session) NodeCrumbs(nodeID int) (nodes []Node, err error) {// {{{
|
|||
nodes = append(nodes, node)
|
||||
}
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) CreateNode(parentID int, name string) (node Node, err error) {// {{{
|
||||
} // }}}
|
||||
func CreateNode(userID, parentID int, name string) (node Node, err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
|
||||
rows, err = db.Queryx(`
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
INSERT INTO node(user_id, parent_id, name)
|
||||
VALUES($1, NULLIF($2, 0)::integer, $3)
|
||||
RETURNING
|
||||
|
|
@ -264,7 +302,7 @@ func (session Session) CreateNode(parentID int, name string) (node Node, err err
|
|||
name,
|
||||
content
|
||||
`,
|
||||
session.UserID,
|
||||
userID,
|
||||
parentID,
|
||||
name,
|
||||
)
|
||||
|
|
@ -283,41 +321,147 @@ func (session Session) CreateNode(parentID int, name string) (node Node, err err
|
|||
node.Complete = true
|
||||
}
|
||||
|
||||
node.Crumbs, err = session.NodeCrumbs(node.ID)
|
||||
node.Crumbs, err = NodeCrumbs(node.ID)
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) UpdateNode(nodeID int, content string, cryptoKeyID int) (err error) {// {{{
|
||||
_, err = db.Exec(`
|
||||
UPDATE node
|
||||
SET
|
||||
content = $1,
|
||||
crypto_key_id = CASE $2::int
|
||||
WHEN 0 THEN NULL
|
||||
ELSE $2
|
||||
END
|
||||
WHERE
|
||||
id = $3 AND
|
||||
user_id = $4
|
||||
`,
|
||||
content,
|
||||
cryptoKeyID,
|
||||
nodeID,
|
||||
session.UserID,
|
||||
)
|
||||
} // }}}
|
||||
func UpdateNode(userID, nodeID, timeOffset int, content string, cryptoKeyID int, markdown bool) (err error) { // {{{
|
||||
if nodeID == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
var timezone string
|
||||
row := service.Db.Conn.QueryRow(`SELECT timezone FROM _webservice.user WHERE id=$1`, userID)
|
||||
err = row.Scan(&timezone)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-000F")
|
||||
return
|
||||
}
|
||||
|
||||
var scannedSchedules, dbSchedules, add, remove []Schedule
|
||||
scannedSchedules = ScanForSchedules(timezone, content)
|
||||
for i := range scannedSchedules {
|
||||
scannedSchedules[i].Node.ID = nodeID
|
||||
scannedSchedules[i].UserID = userID
|
||||
}
|
||||
|
||||
var tsx *sql.Tx
|
||||
tsx, err = service.Db.Conn.Begin()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
dbSchedules, err = RetrieveSchedules(userID, nodeID)
|
||||
if err != nil {
|
||||
tsx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
for _, scanned := range scannedSchedules {
|
||||
found := false
|
||||
for _, db := range dbSchedules {
|
||||
if scanned.IsEqual(db) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
add = append(add, scanned)
|
||||
}
|
||||
}
|
||||
|
||||
for _, db := range dbSchedules {
|
||||
found := false
|
||||
for _, scanned := range scannedSchedules {
|
||||
if db.IsEqual(scanned) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
remove = append(remove, db)
|
||||
}
|
||||
}
|
||||
|
||||
for _, event := range remove {
|
||||
err = event.Delete(tsx)
|
||||
if err != nil {
|
||||
tsx.Rollback()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, event := range add {
|
||||
err = event.Insert(tsx)
|
||||
if err != nil {
|
||||
tsx.Rollback()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if cryptoKeyID > 0 {
|
||||
_, err = tsx.Exec(`
|
||||
UPDATE node
|
||||
SET
|
||||
content = '',
|
||||
content_encrypted = $1,
|
||||
markdown = $5,
|
||||
crypto_key_id = CASE $2::int
|
||||
WHEN 0 THEN NULL
|
||||
ELSE $2
|
||||
END
|
||||
WHERE
|
||||
id = $3 AND
|
||||
user_id = $4
|
||||
`,
|
||||
content,
|
||||
cryptoKeyID,
|
||||
nodeID,
|
||||
userID,
|
||||
markdown,
|
||||
)
|
||||
} else {
|
||||
_, err = tsx.Exec(`
|
||||
UPDATE node
|
||||
SET
|
||||
content = $1,
|
||||
content_encrypted = '',
|
||||
markdown = $5,
|
||||
crypto_key_id = CASE $2::int
|
||||
WHEN 0 THEN NULL
|
||||
ELSE $2
|
||||
END
|
||||
WHERE
|
||||
id = $3 AND
|
||||
user_id = $4
|
||||
`,
|
||||
content,
|
||||
cryptoKeyID,
|
||||
nodeID,
|
||||
userID,
|
||||
markdown,
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
tsx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
err = tsx.Commit()
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) RenameNode(nodeID int, name string) (err error) {// {{{
|
||||
_, err = db.Exec(`
|
||||
} // }}}
|
||||
func RenameNode(userID, nodeID int, name string) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(`
|
||||
UPDATE node SET name = $1 WHERE user_id = $2 AND id = $3
|
||||
`,
|
||||
name,
|
||||
session.UserID,
|
||||
userID,
|
||||
nodeID,
|
||||
)
|
||||
return
|
||||
}// }}}
|
||||
func (session Session) DeleteNode(nodeID int) (err error) {// {{{
|
||||
_, err = db.Exec(`
|
||||
} // }}}
|
||||
func DeleteNode(userID, nodeID int) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(`
|
||||
WITH RECURSIVE nodetree AS (
|
||||
SELECT
|
||||
id, parent_id
|
||||
|
|
@ -336,10 +480,326 @@ func (session Session) DeleteNode(nodeID int) (err error) {// {{{
|
|||
DELETE FROM node WHERE id IN (
|
||||
SELECT id FROM nodetree
|
||||
)`,
|
||||
session.UserID,
|
||||
userID,
|
||||
nodeID,
|
||||
)
|
||||
return
|
||||
}// }}}
|
||||
} // }}}
|
||||
func SearchNodes(userID int, search string) (nodes []Node, err error) { // {{{
|
||||
nodes = []Node{}
|
||||
var rows *sqlx.Rows
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
COALESCE(parent_id, 0) AS parent_id,
|
||||
name,
|
||||
updated
|
||||
FROM node
|
||||
WHERE
|
||||
user_id = $1 AND
|
||||
crypto_key_id IS NULL AND
|
||||
(
|
||||
content ~* $2 OR
|
||||
name ~* $2
|
||||
)
|
||||
ORDER BY
|
||||
updated DESC
|
||||
`, userID, search)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
node := Node{}
|
||||
node.Complete = false
|
||||
if err = rows.StructScan(&node); err != nil {
|
||||
return
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func ChecklistGroupAdd(userID, nodeID int, label string) (item ChecklistGroup, err error) { // {{{
|
||||
var row *sqlx.Row
|
||||
row = service.Db.Conn.QueryRowx(
|
||||
`
|
||||
INSERT INTO checklist_group(node_id, "order", "label")
|
||||
(
|
||||
SELECT
|
||||
$1,
|
||||
MAX("order")+1 AS "order",
|
||||
$2 AS "label"
|
||||
FROM checklist_group g
|
||||
INNER JOIN node n ON g.node_id = n.id
|
||||
WHERE
|
||||
user_id = $3 AND
|
||||
node_id = $1
|
||||
GROUP BY
|
||||
node_id
|
||||
) UNION (
|
||||
SELECT
|
||||
node.id AS node_id,
|
||||
0 AS "order",
|
||||
$2 AS "label"
|
||||
FROM node
|
||||
WHERE
|
||||
user_id = $3 AND
|
||||
node.id = $1
|
||||
)
|
||||
ORDER BY "order" DESC
|
||||
LIMIT 1
|
||||
RETURNING
|
||||
*
|
||||
`,
|
||||
nodeID,
|
||||
label,
|
||||
userID,
|
||||
)
|
||||
err = row.StructScan(&item)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistGroupLabel(userID, checklistGroupID int, label string) (item ChecklistItem, err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
UPDATE checklist_group g
|
||||
SET label = $3
|
||||
FROM node n
|
||||
WHERE
|
||||
g.node_id = n.id AND
|
||||
n.user_id = $1 AND
|
||||
g.id = $2;
|
||||
`,
|
||||
userID,
|
||||
checklistGroupID,
|
||||
label,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistGroupItemAdd(userID, checklistGroupID int, label string) (item ChecklistItem, err error) { // {{{
|
||||
var row *sqlx.Row
|
||||
row = service.Db.Conn.QueryRowx(
|
||||
`
|
||||
INSERT INTO checklist_item(checklist_group_id, "order", "label")
|
||||
(
|
||||
SELECT
|
||||
checklist_group_id,
|
||||
MAX("order")+1 AS "order",
|
||||
$1 AS "label"
|
||||
FROM checklist_item
|
||||
WHERE
|
||||
checklist_group_id = $2
|
||||
GROUP BY
|
||||
checklist_group_id
|
||||
) UNION (
|
||||
SELECT $2 AS checklist_group_id, 0 AS "order", $1 AS "label"
|
||||
)
|
||||
ORDER BY "order" DESC
|
||||
LIMIT 1
|
||||
RETURNING
|
||||
*
|
||||
`,
|
||||
label,
|
||||
checklistGroupID,
|
||||
)
|
||||
err = row.StructScan(&item)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistGroupDelete(userID, checklistGroupID int) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
DELETE
|
||||
FROM checklist_group g
|
||||
USING
|
||||
node n
|
||||
WHERE
|
||||
g.id = $2 AND
|
||||
g.node_id = n.id AND
|
||||
n.user_id = $1
|
||||
`,
|
||||
userID,
|
||||
checklistGroupID,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func ChecklistItemState(userID, checklistItemID int, state bool) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
UPDATE checklist_item i
|
||||
SET checked = $3
|
||||
FROM checklist_group g, node n
|
||||
WHERE
|
||||
i.checklist_group_id = g.id AND
|
||||
g.node_id = n.id AND
|
||||
n.user_id = $1 AND
|
||||
i.id = $2;
|
||||
`,
|
||||
userID,
|
||||
checklistItemID,
|
||||
state,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistItemLabel(userID, checklistItemID int, label string) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
UPDATE checklist_item i
|
||||
SET label = $3
|
||||
FROM checklist_group g, node n
|
||||
WHERE
|
||||
i.checklist_group_id = g.id AND
|
||||
g.node_id = n.id AND
|
||||
n.user_id = $1 AND
|
||||
i.id = $2;
|
||||
`,
|
||||
userID,
|
||||
checklistItemID,
|
||||
label,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistItemDelete(userID, checklistItemID int) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
DELETE
|
||||
FROM checklist_item i
|
||||
USING
|
||||
checklist_group g,
|
||||
node n
|
||||
WHERE
|
||||
i.id = $2 AND
|
||||
i.checklist_group_id = g.id AND
|
||||
g.node_id = n.id AND
|
||||
n.user_id = $1
|
||||
`,
|
||||
userID,
|
||||
checklistItemID,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
func ChecklistItemMove(userID, checklistItemID, afterItemID int) (err error) { // {{{
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`
|
||||
WITH
|
||||
"to" AS (
|
||||
SELECT
|
||||
i.checklist_group_id AS group_id,
|
||||
i."order"
|
||||
FROM checklist_item i
|
||||
INNER JOIN checklist_group g ON i.checklist_group_id = g.id
|
||||
INNER JOIN node n ON g.node_id = n.id
|
||||
WHERE
|
||||
n.user_id = $1 AND
|
||||
i.id = $3
|
||||
),
|
||||
|
||||
update_order AS (
|
||||
UPDATE checklist_item
|
||||
SET
|
||||
"order" =
|
||||
CASE
|
||||
WHEN checklist_item."order" <= "to"."order" THEN checklist_item."order" - 1
|
||||
WHEN checklist_item."order" > "to"."order" THEN checklist_item."order" + 1
|
||||
END
|
||||
FROM "to"
|
||||
WHERE
|
||||
checklist_item.id != $2 AND
|
||||
checklist_item.checklist_group_id = "to".group_id
|
||||
)
|
||||
|
||||
UPDATE checklist_item
|
||||
SET
|
||||
checklist_group_id = "to".group_id,
|
||||
"order" = "to"."order"
|
||||
FROM "to"
|
||||
WHERE
|
||||
checklist_item.id = $2
|
||||
`,
|
||||
userID,
|
||||
checklistItemID,
|
||||
afterItemID,
|
||||
)
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func (node *Node) retrieveChecklist() (err error) { // {{{
|
||||
var rows *sqlx.Rows
|
||||
rows, err = service.Db.Conn.Queryx(`
|
||||
SELECT
|
||||
g.id AS group_id,
|
||||
g.order AS group_order,
|
||||
g.label AS group_label,
|
||||
|
||||
COALESCE(i.id, 0) AS item_id,
|
||||
COALESCE(i.order, 0) AS item_order,
|
||||
COALESCE(i.label, '') AS item_label,
|
||||
COALESCE(i.checked, false) AS checked
|
||||
|
||||
FROM public.checklist_group g
|
||||
LEFT JOIN public.checklist_item i ON i.checklist_group_id = g.id
|
||||
WHERE
|
||||
g.node_id = $1
|
||||
ORDER BY
|
||||
g.order DESC,
|
||||
i.order DESC
|
||||
`, node.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
groups := make(map[int]*ChecklistGroup)
|
||||
var found bool
|
||||
var group *ChecklistGroup
|
||||
var item ChecklistItem
|
||||
for rows.Next() {
|
||||
row := struct {
|
||||
GroupID int `db:"group_id"`
|
||||
GroupOrder int `db:"group_order"`
|
||||
GroupLabel string `db:"group_label"`
|
||||
|
||||
ItemID int `db:"item_id"`
|
||||
ItemOrder int `db:"item_order"`
|
||||
ItemLabel string `db:"item_label"`
|
||||
Checked bool
|
||||
}{}
|
||||
err = rows.StructScan(&row)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if group, found = groups[row.GroupID]; !found {
|
||||
group = new(ChecklistGroup)
|
||||
group.ID = row.GroupID
|
||||
group.NodeID = node.ID
|
||||
group.Order = row.GroupOrder
|
||||
group.Label = row.GroupLabel
|
||||
group.Items = []ChecklistItem{}
|
||||
groups[group.ID] = group
|
||||
}
|
||||
|
||||
item = ChecklistItem{}
|
||||
item.ID = row.ItemID
|
||||
item.GroupID = row.GroupID
|
||||
item.Order = row.ItemOrder
|
||||
item.Label = row.ItemLabel
|
||||
item.Checked = row.Checked
|
||||
|
||||
if item.ID > 0 {
|
||||
group.Items = append(group.Items, item)
|
||||
}
|
||||
}
|
||||
|
||||
node.ChecklistGroups = []ChecklistGroup{}
|
||||
for _, group := range groups {
|
||||
node.ChecklistGroups = append(node.ChecklistGroups, *group)
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
|
|
|||
15
notification/factory.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package notification
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
)
|
||||
|
||||
func ServiceFactory(t string, config []byte, prio int, ackURL string) (Service, error) {
|
||||
switch t {
|
||||
case "NTFY":
|
||||
return NewNTFY(config, prio, ackURL)
|
||||
}
|
||||
|
||||
return nil, werr.New("Unknown notification service, '%s'", t).WithCode("002-0000")
|
||||
}
|
||||
72
notification/ntfy.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package notification
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type NTFY struct {
|
||||
URL string
|
||||
Prio int
|
||||
AcknowledgeURL string
|
||||
}
|
||||
|
||||
func NewNTFY(config []byte, prio int, ackURL string) (instance NTFY, err error) {
|
||||
err = json.Unmarshal(config, &instance)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0001").WithData(config)
|
||||
return
|
||||
}
|
||||
instance.Prio = prio
|
||||
instance.AcknowledgeURL = ackURL
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
func (ntfy NTFY) GetPrio() int {
|
||||
return ntfy.Prio
|
||||
}
|
||||
|
||||
func (ntfy NTFY) Send(uuid string, msg []byte) (err error) {
|
||||
var req *http.Request
|
||||
var res *http.Response
|
||||
req, err = http.NewRequest("POST", ntfy.URL, bytes.NewReader(msg))
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0002").WithData(ntfy.URL)
|
||||
return
|
||||
}
|
||||
|
||||
ackURL := fmt.Sprintf("http, OK, %s/notification/ack?uuid=%s", ntfy.AcknowledgeURL, uuid)
|
||||
req.Header.Add("X-Actions", ackURL)
|
||||
req.Header.Add("X-Priority", "5")
|
||||
req.Header.Add("X-Tags", "calendar")
|
||||
|
||||
res, err = http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0003")
|
||||
return
|
||||
}
|
||||
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
if res.StatusCode != 200 {
|
||||
err = werr.New("Invalid NTFY response").WithCode("002-0004").WithData(body)
|
||||
return
|
||||
}
|
||||
|
||||
ntfyResp := struct {
|
||||
ID string
|
||||
}{}
|
||||
err = json.Unmarshal(body, &ntfyResp)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0005").WithData(body)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
60
notification/pkg.go
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package notification
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
_ "fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
GetPrio() int
|
||||
Send(string, []byte) error
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
services map[int][]Service
|
||||
}
|
||||
|
||||
func NewManager() (nm Manager) {
|
||||
nm.services = make(map[int][]Service, 32)
|
||||
return
|
||||
}
|
||||
|
||||
func (nm *Manager) AddService(userID int, service Service) {
|
||||
var services []Service
|
||||
var found bool
|
||||
if services, found = nm.services[userID]; !found {
|
||||
services = []Service{}
|
||||
}
|
||||
|
||||
services = append(services, service)
|
||||
slices.SortFunc(services, func(a, b Service) int {
|
||||
if a.GetPrio() < b.GetPrio() {
|
||||
return -1
|
||||
}
|
||||
if a.GetPrio() > b.GetPrio() {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
nm.services[userID] = services
|
||||
}
|
||||
|
||||
func (nm *Manager) Send(userID int, uuid string, msg []byte) (err error) {
|
||||
|
||||
services, found := nm.services[userID]
|
||||
if !found {
|
||||
return werr.New("No notification services defined for user ID %d", userID).WithCode("002-0008")
|
||||
}
|
||||
|
||||
for _, service := range services {
|
||||
if err = service.Send(uuid, msg); err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
75
notification_manager.go
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Internal
|
||||
"notes/notification"
|
||||
|
||||
// Standard
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type DbNotificationService struct {
|
||||
ID int
|
||||
UserID int `json:"user_id"`
|
||||
Service string
|
||||
Configuration string
|
||||
Prio int
|
||||
}
|
||||
|
||||
func InitNotificationManager() (err error) {// {{{
|
||||
var dbServices []DbNotificationService
|
||||
var row *sql.Row
|
||||
|
||||
row = service.Db.Conn.QueryRow(`
|
||||
WITH services AS (
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
prio,
|
||||
service,
|
||||
configuration::varchar
|
||||
FROM notification n
|
||||
ORDER BY
|
||||
user_id ASC,
|
||||
prio ASC
|
||||
)
|
||||
SELECT COALESCE(jsonb_agg(s.*), '[]')
|
||||
FROM services s
|
||||
`,
|
||||
)
|
||||
var dbData []byte
|
||||
err = row.Scan(&dbData)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0006")
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(dbData, &dbServices)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0007")
|
||||
return
|
||||
}
|
||||
|
||||
notificationManager = notification.NewManager()
|
||||
var service notification.Service
|
||||
for _, dbService := range dbServices {
|
||||
service, err = notification.ServiceFactory(
|
||||
dbService.Service,
|
||||
[]byte(dbService.Configuration),
|
||||
dbService.Prio,
|
||||
config.Application.NotificationBaseURL,
|
||||
)
|
||||
notificationManager.AddService(dbService.UserID, service)
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
|
||||
func AcknowledgeNotification(uuid string) (err error) {// {{{
|
||||
_, err = service.Db.Conn.Exec(`UPDATE schedule SET acknowledged=true WHERE schedule_uuid=$1`, uuid)
|
||||
return
|
||||
}// }}}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
|
@ -18,6 +21,8 @@ func responseError(w http.ResponseWriter, err error) {
|
|||
}
|
||||
resJSON, _ := json.Marshal(res)
|
||||
|
||||
|
||||
werr.Wrap(err).Log()
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.Write(resJSON)
|
||||
}
|
||||
|
|
|
|||
289
schedule.go
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fmt.Printf("")
|
||||
}
|
||||
|
||||
type Schedule struct {
|
||||
ID int
|
||||
UserID int `json:"user_id" db:"user_id"`
|
||||
Node Node
|
||||
ScheduleUUID string `db:"schedule_uuid"`
|
||||
Time time.Time
|
||||
RemindMinutes int `db:"remind_minutes"`
|
||||
Description string
|
||||
Acknowledged bool
|
||||
}
|
||||
|
||||
func scheduleHandler() { // {{{
|
||||
// Wait for the approximate minute.
|
||||
wait := 60000 - time.Now().Sub(time.Now().Truncate(time.Minute)).Milliseconds()
|
||||
logger.Info("schedule", "wait", wait/1000)
|
||||
time.Sleep(time.Millisecond * time.Duration(wait))
|
||||
tick := time.NewTicker(time.Minute)
|
||||
for {
|
||||
schedules := ExpiredSchedules()
|
||||
for _, event := range schedules {
|
||||
notificationManager.Send(
|
||||
event.UserID,
|
||||
event.ScheduleUUID,
|
||||
[]byte(
|
||||
fmt.Sprintf(
|
||||
"%s\n%s",
|
||||
event.Time.Format("2006-01-02 15:04"),
|
||||
event.Description,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
<-tick.C
|
||||
}
|
||||
} // }}}
|
||||
|
||||
func ScanForSchedules(timezone string, content string) (schedules []Schedule) { // {{{
|
||||
schedules = []Schedule{}
|
||||
|
||||
rxp := regexp.MustCompile(`\{\s*([0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}(?::[0-9]{2})?)\s*\,\s*(?:(\d+)\s*(h|min)\s*,)?\s*([^\]]+?)\s*\}`)
|
||||
foundSchedules := rxp.FindAllStringSubmatch(content, -1)
|
||||
|
||||
for _, data := range foundSchedules {
|
||||
// Missing seconds
|
||||
if strings.Count(data[1], ":") == 1 {
|
||||
data[1] = data[1] + ":00"
|
||||
}
|
||||
|
||||
logger.Info("time", "parse", data[1])
|
||||
location, err := time.LoadLocation(timezone)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-00010")
|
||||
return
|
||||
}
|
||||
|
||||
timestamp, err := time.ParseInLocation("2006-01-02 15:04:05", data[1], location)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Reminder
|
||||
var remindMinutes int
|
||||
if data[2] != "" && data[3] != "" {
|
||||
value, _ := strconv.Atoi(data[2])
|
||||
unit := strings.ToLower(data[3])
|
||||
switch unit {
|
||||
case "min":
|
||||
remindMinutes = value
|
||||
case "h":
|
||||
remindMinutes = value * 60
|
||||
}
|
||||
}
|
||||
|
||||
schedule := Schedule{
|
||||
Time: timestamp,
|
||||
RemindMinutes: remindMinutes,
|
||||
Description: data[4],
|
||||
}
|
||||
schedules = append(schedules, schedule)
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
func RetrieveSchedules(userID int, nodeID int) (schedules []Schedule, err error) { // {{{
|
||||
schedules = []Schedule{}
|
||||
|
||||
res := service.Db.Conn.QueryRow(`
|
||||
WITH schedule_events AS (
|
||||
SELECT
|
||||
s.id,
|
||||
s.user_id,
|
||||
json_build_object('id', s.node_id) AS node,
|
||||
s.schedule_uuid,
|
||||
(time - MAKE_INTERVAL(mins => s.remind_minutes)) AT TIME ZONE u.timezone AS time,
|
||||
s.description,
|
||||
s.acknowledged
|
||||
FROM schedule s
|
||||
INNER JOIN _webservice.user u ON s.user_id = u.id
|
||||
WHERE
|
||||
user_id=$1 AND
|
||||
CASE
|
||||
WHEN $2 > 0 THEN node_id = $2
|
||||
ELSE true
|
||||
END
|
||||
)
|
||||
SELECT
|
||||
COALESCE(jsonb_agg(s.*), '[]'::jsonb)
|
||||
FROM schedule_events s
|
||||
`,
|
||||
userID,
|
||||
nodeID,
|
||||
)
|
||||
|
||||
var data []byte
|
||||
err = res.Scan(&data)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-000E")
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &schedules)
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func (a Schedule) IsEqual(b Schedule) bool { // {{{
|
||||
return a.UserID == b.UserID &&
|
||||
a.Node.ID == b.Node.ID &&
|
||||
a.Time.Equal(b.Time) &&
|
||||
a.RemindMinutes == b.RemindMinutes &&
|
||||
a.Description == b.Description
|
||||
} // }}}
|
||||
func (s *Schedule) Insert(queryable Queryable) error { // {{{
|
||||
res := queryable.QueryRow(`
|
||||
INSERT INTO schedule(user_id, node_id, time, remind_minutes, description)
|
||||
VALUES($1, $2, $3, $4, $5)
|
||||
RETURNING id
|
||||
`,
|
||||
s.UserID,
|
||||
s.Node.ID,
|
||||
s.Time.Format("2006-01-02 15:04:05"),
|
||||
s.RemindMinutes,
|
||||
s.Description,
|
||||
)
|
||||
|
||||
err := res.Scan(&s.ID)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-000D")
|
||||
}
|
||||
return err
|
||||
} // }}}
|
||||
func (s *Schedule) Delete(queryable Queryable) error { // {{{
|
||||
_, err := queryable.Exec(`
|
||||
DELETE FROM schedule
|
||||
WHERE
|
||||
user_id = $1 AND
|
||||
id = $2
|
||||
`,
|
||||
s.UserID,
|
||||
s.ID,
|
||||
)
|
||||
return err
|
||||
} // }}}
|
||||
|
||||
func ExpiredSchedules() (schedules []Schedule) { // {{{
|
||||
schedules = []Schedule{}
|
||||
|
||||
res, err := service.Db.Conn.Queryx(`
|
||||
SELECT
|
||||
s.id,
|
||||
s.user_id,
|
||||
s.node_id,
|
||||
s.schedule_uuid,
|
||||
(s.time - MAKE_INTERVAL(mins => s.remind_minutes)) AT TIME ZONE u.timezone AS time,
|
||||
s.description
|
||||
FROM schedule s
|
||||
INNER JOIN _webservice.user u ON s.user_id = u.id
|
||||
WHERE
|
||||
(time - MAKE_INTERVAL(mins => remind_minutes)) AT TIME ZONE u.timezone < NOW() AND
|
||||
NOT acknowledged
|
||||
ORDER BY
|
||||
time ASC
|
||||
`)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0009")
|
||||
return
|
||||
}
|
||||
defer res.Close()
|
||||
|
||||
for res.Next() {
|
||||
s := Schedule{}
|
||||
if err = res.Scan(&s.ID, &s.UserID, &s.Node.ID, &s.ScheduleUUID, &s.Time, &s.Description); err != nil {
|
||||
werr.Wrap(err).WithCode("002-000a")
|
||||
continue
|
||||
}
|
||||
schedules = append(schedules, s)
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
func FutureSchedules(userID int, nodeID int, start time.Time, end time.Time) (schedules []Schedule, err error) { // {{{
|
||||
schedules = []Schedule{}
|
||||
|
||||
var foo string
|
||||
row := service.Db.Conn.QueryRow(`SELECT TO_CHAR($1::date AT TIME ZONE 'UTC', 'yyyy-mm-dd HH24:MI')`, start)
|
||||
err = row.Scan(&foo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
logger.Info("FOO", "date", foo)
|
||||
|
||||
res := service.Db.Conn.QueryRow(`
|
||||
WITH schedule_events AS (
|
||||
SELECT
|
||||
s.id,
|
||||
s.user_id,
|
||||
jsonb_build_object(
|
||||
'id', n.id,
|
||||
'name', n.name,
|
||||
'updated', n.updated
|
||||
) AS node,
|
||||
s.schedule_uuid,
|
||||
time AT TIME ZONE u.timezone AS time,
|
||||
s.description,
|
||||
s.acknowledged,
|
||||
s.remind_minutes AS RemindMinutes
|
||||
FROM schedule s
|
||||
INNER JOIN _webservice.user u ON s.user_id = u.id
|
||||
INNER JOIN node n ON s.node_id = n.id
|
||||
WHERE
|
||||
s.user_id = $1 AND
|
||||
(
|
||||
CASE
|
||||
WHEN $2 > 0 THEN n.id = $2
|
||||
ELSE true
|
||||
END
|
||||
) AND (
|
||||
CASE WHEN TO_CHAR($3::date, 'yyyy-mm-dd HH24:MI') = '0001-01-01 00:00' THEN TRUE
|
||||
ELSE (s.time AT TIME ZONE u.timezone) >= $3
|
||||
END
|
||||
) AND (
|
||||
CASE WHEN TO_CHAR($4::date, 'yyyy-mm-dd HH24:MI') = '0001-01-01 00:00' THEN TRUE
|
||||
ELSE (s.time AT TIME ZONE u.timezone) <= $4
|
||||
END
|
||||
) AND
|
||||
time >= NOW() AND
|
||||
NOT acknowledged
|
||||
)
|
||||
SELECT
|
||||
COALESCE(jsonb_agg(s.*), '[]'::jsonb)
|
||||
FROM schedule_events s
|
||||
`,
|
||||
userID,
|
||||
nodeID,
|
||||
start,
|
||||
end,
|
||||
)
|
||||
var j []byte
|
||||
err = res.Scan(&j)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-000B").WithData(userID)
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(j, &schedules)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithCode("002-0010").WithData(string(j)).Log()
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
119
session.go
|
|
@ -1,119 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// Standard
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
UUID string
|
||||
UserID int
|
||||
Created time.Time
|
||||
}
|
||||
|
||||
func CreateSession() (session Session, err error) {// {{{
|
||||
var rows *sql.Rows
|
||||
if rows, err = db.Query(`
|
||||
INSERT INTO public.session(uuid)
|
||||
VALUES(gen_random_uuid())
|
||||
RETURNING uuid, created`,
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
if rows.Next() {
|
||||
rows.Scan(&session.UUID, &session.Created)
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
|
||||
func sessionUUID(r *http.Request) (string, error) {// {{{
|
||||
headers := r.Header["X-Session-Id"]
|
||||
if len(headers) > 0 {
|
||||
return headers[0], nil
|
||||
}
|
||||
return "", errors.New("Invalid session")
|
||||
}// }}}
|
||||
func ValidateSession(r *http.Request, notFoundIsError bool) (session Session, found bool, err error) {// {{{
|
||||
var uuid string
|
||||
if uuid, err = sessionUUID(r); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
session.UUID = uuid
|
||||
if found, err = session.Retrieve(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if notFoundIsError && !found {
|
||||
err = errors.New("Invalid session")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
|
||||
func (session *Session) Retrieve() (found bool, err error) {// {{{
|
||||
var rows *sql.Rows
|
||||
if rows, err = db.Query(`
|
||||
SELECT
|
||||
uuid, user_id, created
|
||||
FROM public.session
|
||||
WHERE
|
||||
uuid = $1 AND
|
||||
created + $2::interval >= NOW()
|
||||
`,
|
||||
session.UUID,
|
||||
fmt.Sprintf("%d days", config.Session.DaysValid),
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
found = false
|
||||
if rows.Next() {
|
||||
found = true
|
||||
rows.Scan(&session.UUID, &session.UserID, &session.Created)
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
func (session *Session) Authenticate(username, password string) (authenticated bool, err error) {// {{{
|
||||
var rows *sql.Rows
|
||||
if rows, err = db.Query(`
|
||||
SELECT id
|
||||
FROM public.user
|
||||
WHERE
|
||||
username=$1 AND
|
||||
password=$2
|
||||
`,
|
||||
username,
|
||||
password,
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
if rows.Next() {
|
||||
rows.Scan(&session.UserID)
|
||||
authenticated = session.UserID > 0
|
||||
}
|
||||
|
||||
if authenticated {
|
||||
_, err = db.Exec("UPDATE public.session SET user_id=$1 WHERE uuid=$2", session.UserID, session.UUID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}// }}}
|
||||
|
||||
|
||||
// vim: foldmethod=marker
|
||||
5
sql/00011.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE node ADD COLUMN content_encrypted TEXT NOT NULL DEFAULT '';
|
||||
UPDATE node SET content_encrypted = content, content = '' WHERE crypto_key_id IS NOT NULL;
|
||||
|
||||
CREATE EXTENSION pg_trgm;
|
||||
CREATE INDEX node_content_index ON node USING gin (content gin_trgm_ops);
|
||||
2
sql/00012.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
DROP INDEX node_content_index;
|
||||
CREATE INDEX node_search_index ON node USING gin (name gin_trgm_ops, content gin_trgm_ops);
|
||||
1
sql/00013.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE public.node ADD COLUMN markdown bool NOT NULL DEFAULT false;
|
||||
18
sql/00014.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE checklist_group (
|
||||
id serial NOT NULL,
|
||||
node_id int4 NOT NULL,
|
||||
"order" int NOT NULL DEFAULT 0,
|
||||
label varchar NOT NULL,
|
||||
CONSTRAINT checklist_group_pk PRIMARY KEY (id),
|
||||
CONSTRAINT checklist_group_node_fk FOREIGN KEY (node_id) REFERENCES public."node"(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE checklist_item (
|
||||
id serial NOT NULL,
|
||||
checklist_group_id int4 NOT NULL,
|
||||
"order" int NOT NULL DEFAULT 0,
|
||||
label varchar NOT NULL,
|
||||
checked bool NOT NULL DEFAULT false,
|
||||
CONSTRAINT checklist_item_pk PRIMARY KEY (id),
|
||||
CONSTRAINT checklist_group_item_fk FOREIGN KEY (checklist_group_id) REFERENCES public."checklist_group"(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
)
|
||||
14
sql/00015.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
CREATE TABLE public.schedule (
|
||||
id SERIAL NOT NULL,
|
||||
user_id INT4 NOT NULL,
|
||||
node_id INT4 NOT NULL,
|
||||
schedule_uuid CHAR(36) DEFAULT GEN_RANDOM_UUID() NOT NULL,
|
||||
"time" TIMESTAMP NOT NULL,
|
||||
description VARCHAR DEFAULT '' NOT NULL,
|
||||
acknowledged BOOL DEFAULT false NOT NULL,
|
||||
|
||||
CONSTRAINT schedule_pk PRIMARY KEY (id),
|
||||
CONSTRAINT schedule_uuid UNIQUE (schedule_uuid),
|
||||
CONSTRAINT schedule_node_fk FOREIGN KEY (node_id) REFERENCES public.node(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT schedule_user_fk FOREIGN KEY (user_id) REFERENCES "_webservice"."user"(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
1
sql/00016.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE public.schedule ADD CONSTRAINT schedule_event UNIQUE (user_id, node_id, "time", description);
|
||||
11
sql/00017.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
CREATE TABLE public.notification (
|
||||
id SERIAl NOT NULL,
|
||||
user_id INT4 NOT NULL,
|
||||
service VARCHAR DEFAULT 'NTFY' NOT NULL,
|
||||
"configuration" JSONB DEFAULT '{}' NOT NULL,
|
||||
prio INT DEFAULT 0 NOT NULL,
|
||||
|
||||
CONSTRAINT notification_pk PRIMARY KEY (id),
|
||||
CONSTRAINT notification_unique UNIQUE (user_id,prio),
|
||||
CONSTRAINT notification_user_fk FOREIGN KEY (user_id) REFERENCES "_webservice"."user"(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
2
sql/00018.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE public.schedule ALTER COLUMN "time" TYPE timestamptz USING "time"::timestamptz;
|
||||
|
||||
1
sql/00019.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE public.schedule ADD COLUMN remind_minutes int NOT NULL DEFAULT 0;
|
||||
2
sql/00020.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE _webservice."user" ADD timezone varchar DEFAULT 'UTC' NOT NULL;
|
||||
ALTER TABLE public.schedule ALTER COLUMN "time" TYPE timestamp USING "time"::timestamp;
|
||||
1
sql/00021.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE public.node ALTER COLUMN updated TYPE timestamptz USING updated::timestamptz;
|
||||
|
|
@ -1,33 +1,53 @@
|
|||
/*
|
||||
@theme_gradient: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
@theme_gradient: linear-gradient(to right, #f5af19, #f12711);
|
||||
@theme_gradient: linear-gradient(to right, #fdc830, #f37335);
|
||||
@theme_gradient: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
@theme_gradient: linear-gradient(to right, #659999, #f4791f);
|
||||
*/
|
||||
#login {
|
||||
height: 100%;
|
||||
background: #eee;
|
||||
}
|
||||
#login .header {
|
||||
background: linear-gradient(to right, #3e5151, #decba4);
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
#login .header h1 {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
#login .fields {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
height: 100%;
|
||||
padding: 32px;
|
||||
}
|
||||
#login input {
|
||||
max-width: 300px;
|
||||
#login .fields input {
|
||||
margin-bottom: 32px;
|
||||
width: 100%;
|
||||
border: 0px;
|
||||
border-bottom: 1px solid #444;
|
||||
font-size: 18pt;
|
||||
border: 1px solid #444;
|
||||
padding: 8px;
|
||||
width: 100%;
|
||||
font-size: 1.25em;
|
||||
background-color: #fff;
|
||||
}
|
||||
#login input:focus {
|
||||
#login .fields input:focus {
|
||||
outline: none;
|
||||
}
|
||||
#login button {
|
||||
max-width: 300px;
|
||||
#login .fields button {
|
||||
border: 1px solid #666;
|
||||
background: #fff;
|
||||
color: #444;
|
||||
padding: 16px 32px;
|
||||
font-size: 1em;
|
||||
padding: 12px 24px;
|
||||
font-size: 1.25em;
|
||||
align-self: center;
|
||||
}
|
||||
#login button:hover {
|
||||
#login .fields button:hover {
|
||||
background: #ddd;
|
||||
}
|
||||
#login .auth-failed {
|
||||
#login .fields .auth-failed {
|
||||
margin-top: 32px;
|
||||
color: #a00;
|
||||
background: #fff;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
@theme_gradient: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
@theme_gradient: linear-gradient(to right, #f5af19, #f12711);
|
||||
@theme_gradient: linear-gradient(to right, #fdc830, #f37335);
|
||||
@theme_gradient: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
@theme_gradient: linear-gradient(to right, #659999, #f4791f);
|
||||
*/
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
|
@ -6,9 +13,17 @@ html {
|
|||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
*,
|
||||
*:focus,
|
||||
*:hover {
|
||||
outline: none;
|
||||
}
|
||||
[onClick] {
|
||||
cursor: pointer;
|
||||
}
|
||||
label {
|
||||
user-select: none;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
margin: 0px;
|
||||
|
|
@ -19,12 +34,16 @@ body {
|
|||
height: 100%;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 0px;
|
||||
font-size: 1.5em;
|
||||
font-size: 1.25em;
|
||||
color: #518048;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 32px;
|
||||
font-size: 1.25em;
|
||||
font-size: 1em;
|
||||
color: #518048;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1em;
|
||||
}
|
||||
button {
|
||||
font-size: 1em;
|
||||
|
|
@ -48,6 +67,13 @@ button {
|
|||
border: 2px solid #000;
|
||||
box-shadow: 5px 5px 8px 0px rgba(0, 0, 0, 0.5);
|
||||
z-index: 1025;
|
||||
width: min-content;
|
||||
}
|
||||
#menu .section {
|
||||
padding: 16px 16px 0px 16px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
color: #c84a37;
|
||||
}
|
||||
#menu .item {
|
||||
padding: 16px;
|
||||
|
|
@ -127,18 +153,18 @@ button {
|
|||
#properties .key label {
|
||||
margin-left: 8px;
|
||||
}
|
||||
#properties .checks {
|
||||
display: grid;
|
||||
grid-template-columns: min-content 1fr;
|
||||
grid-gap: 4px 8px;
|
||||
}
|
||||
header {
|
||||
display: grid;
|
||||
grid-area: header;
|
||||
grid-template-columns: min-content 1fr repeat(3, min-content);
|
||||
grid-template-columns: min-content 1fr repeat(6, min-content);
|
||||
align-items: center;
|
||||
padding: 8px 0px;
|
||||
color: #333c11;
|
||||
background: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
background: linear-gradient(to right, #f5af19, #f12711);
|
||||
background: linear-gradient(to right, #fdc830, #f37335);
|
||||
background: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
background: linear-gradient(to right, #659999, #f4791f);
|
||||
background: linear-gradient(to right, #3e5151, #decba4);
|
||||
color: #fff;
|
||||
}
|
||||
|
|
@ -159,17 +185,17 @@ header .name {
|
|||
padding-left: 16px;
|
||||
font-size: 1.25em;
|
||||
}
|
||||
header .add {
|
||||
padding-right: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
header .add img {
|
||||
cursor: pointer;
|
||||
height: 24px;
|
||||
}
|
||||
header .markdown,
|
||||
header .checklist,
|
||||
header .search,
|
||||
header .add,
|
||||
header .keys {
|
||||
padding-right: 16px;
|
||||
}
|
||||
header .markdown img,
|
||||
header .checklist img,
|
||||
header .search img,
|
||||
header .add img,
|
||||
header .keys img {
|
||||
cursor: pointer;
|
||||
height: 24px;
|
||||
|
|
@ -186,6 +212,7 @@ header .menu {
|
|||
padding: 16px;
|
||||
background-color: #333;
|
||||
color: #ddd;
|
||||
z-index: 100;
|
||||
}
|
||||
#tree .node {
|
||||
display: grid;
|
||||
|
|
@ -200,6 +227,7 @@ header .menu {
|
|||
#tree .node .name {
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
#tree .node .name:hover {
|
||||
color: #ecbf00;
|
||||
|
|
@ -274,6 +302,11 @@ header .menu {
|
|||
margin-bottom: 32px;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
#notes-version {
|
||||
margin-top: 64px;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
}
|
||||
#node-content.encrypted {
|
||||
color: #a00;
|
||||
}
|
||||
|
|
@ -293,6 +326,174 @@ header .menu {
|
|||
background: #f5f5f5;
|
||||
padding-top: 16px;
|
||||
}
|
||||
#markdown {
|
||||
color: #333;
|
||||
grid-area: content;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 8px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
#markdown table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
#markdown table th,
|
||||
#markdown table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
#markdown code {
|
||||
background: #e6eeee;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
#markdown pre {
|
||||
background: #f5f5f5;
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
#markdown pre > code {
|
||||
background: unset;
|
||||
padding: 0px;
|
||||
border-radius: 0px;
|
||||
}
|
||||
#checklist {
|
||||
grid-area: checklist;
|
||||
color: #333;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 8px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
#checklist .header {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, min-content);
|
||||
align-items: center;
|
||||
grid-gap: 0 16px;
|
||||
}
|
||||
#checklist .header img {
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#checklist .header + .checklist-group.edit {
|
||||
margin-top: 16px;
|
||||
}
|
||||
#checklist .checklist-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, min-content);
|
||||
align-items: center;
|
||||
grid-gap: 0 8px;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 8px;
|
||||
font-weight: bold;
|
||||
}
|
||||
#checklist .checklist-group .label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
#checklist .checklist-group .label.ok {
|
||||
color: #54b356;
|
||||
}
|
||||
#checklist .checklist-group .label.error {
|
||||
color: #d13636;
|
||||
}
|
||||
#checklist .checklist-group.edit {
|
||||
margin-top: 32px;
|
||||
border-bottom: 1px solid #aaa;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
#checklist .checklist-group:not(.edit) .reorder {
|
||||
display: none;
|
||||
}
|
||||
#checklist .checklist-group:not(.edit) img {
|
||||
display: none;
|
||||
}
|
||||
#checklist .checklist-group img {
|
||||
height: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#checklist .checklist-item {
|
||||
transform: translate(0, 0);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, min-content);
|
||||
grid-gap: 0 8px;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
border-bottom: 2px solid #fff;
|
||||
}
|
||||
#checklist .checklist-item.checked {
|
||||
text-decoration: line-through;
|
||||
color: #aaa;
|
||||
}
|
||||
#checklist .checklist-item.drag-target {
|
||||
border-bottom: 2px solid #71c837;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"] {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
background-color: #fff;
|
||||
margin: 0 2px 0 0;
|
||||
font: inherit;
|
||||
color: currentColor;
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
border: 0.15em solid currentColor;
|
||||
border-radius: 0.15em;
|
||||
transform: translateY(-0.075em);
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
#checklist .checklist-item label.ok {
|
||||
color: #54b356;
|
||||
}
|
||||
#checklist .checklist-item label.error {
|
||||
color: #d13636;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"].ok {
|
||||
border: 0.15em solid #54b356;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"].ok::before {
|
||||
box-shadow: inset 1em 1em #54b356;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"].error {
|
||||
border: 0.15em solid #d13636;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"].error::before {
|
||||
box-shadow: inset 1em 1em #d13636;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"]::before {
|
||||
content: "";
|
||||
width: 0.7em;
|
||||
height: 0.7em;
|
||||
transform: scale(0);
|
||||
transition: 120ms transform ease-in-out;
|
||||
box-shadow: inset 1em 1em #666;
|
||||
}
|
||||
#checklist .checklist-item input[type="checkbox"]:checked::before {
|
||||
transform: scale(1);
|
||||
}
|
||||
#checklist .checklist-item.edit input[type="checkbox"] {
|
||||
margin-left: 8px;
|
||||
}
|
||||
#checklist .checklist-item:not(.edit) .reorder {
|
||||
display: none;
|
||||
}
|
||||
#checklist .checklist-item:not(.edit) img {
|
||||
display: none;
|
||||
}
|
||||
#checklist .checklist-item img {
|
||||
height: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#checklist .checklist-item label {
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* ============================================================= *
|
||||
* Textarea replicates the height of an element expanding height *
|
||||
* ============================================================= */
|
||||
|
|
@ -331,7 +532,7 @@ header .menu {
|
|||
grid-area: 1 / 1 / 2 / 2;
|
||||
}
|
||||
/* ============================================================= */
|
||||
#file-section {
|
||||
#schedule-section {
|
||||
grid-area: files;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
|
|
@ -341,6 +542,23 @@ header .menu {
|
|||
border-radius: 8px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 32px;
|
||||
color: #000;
|
||||
}
|
||||
#schedule-section .header {
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
#file-section {
|
||||
grid-area: schedule;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 32px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
#file-section .header {
|
||||
font-weight: bold;
|
||||
|
|
@ -439,12 +657,12 @@ header .menu {
|
|||
}
|
||||
.layout-tree {
|
||||
display: grid;
|
||||
grid-template-areas: "header header" "tree crumbs" "tree child-nodes" "tree name" "tree content" "tree files" "tree blank";
|
||||
grid-template-areas: "header header" "tree crumbs" "tree child-nodes" "tree name" "tree content" "tree checklist" "tree schedule" "tree files" "tree blank";
|
||||
grid-template-columns: min-content 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* files */ 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
||||
/* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
.layout-tree-only {
|
||||
display: grid;
|
||||
|
|
@ -453,7 +671,7 @@ header .menu {
|
|||
grid-template-rows: min-content /* header */ 1fr;
|
||||
/* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
.layout-tree-only #crumbs {
|
||||
display: none;
|
||||
|
|
@ -474,14 +692,17 @@ header .menu {
|
|||
display: block;
|
||||
}
|
||||
.layout-crumbs {
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "files" "blank";
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "checklist" "schedule" "files" "blank";
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* files */ 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
||||
/* blank */
|
||||
}
|
||||
.layout-crumbs #tree {
|
||||
display: none;
|
||||
}
|
||||
.layout-crumbs #checklist {
|
||||
padding: 16px;
|
||||
}
|
||||
.layout-keys {
|
||||
display: grid;
|
||||
grid-template-areas: "header" "keys";
|
||||
|
|
@ -512,59 +733,145 @@ header .menu {
|
|||
.layout-keys #keys {
|
||||
display: block;
|
||||
}
|
||||
#app {
|
||||
#app.login {
|
||||
padding-top: 64px;
|
||||
display: grid;
|
||||
grid-template-areas: "header header" "tree crumbs" "tree child-nodes" "tree name" "tree content" "tree files" "tree blank";
|
||||
grid-template-columns: minmax(min-content, 300px);
|
||||
justify-content: center;
|
||||
}
|
||||
#app.node {
|
||||
display: grid;
|
||||
grid-template-areas: "header header" "tree crumbs" "tree child-nodes" "tree name" "tree content" "tree checklist" "tree schedule" "tree files" "tree blank";
|
||||
grid-template-columns: min-content 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* files */ 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
||||
/* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
#app.toggle-tree {
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "files" "blank";
|
||||
#app.node.toggle-tree {
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "checklist" "schedule" "files" "blank";
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* files */ 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
||||
/* blank */
|
||||
}
|
||||
#app.toggle-tree #tree {
|
||||
#app.node.toggle-tree #tree {
|
||||
display: none;
|
||||
}
|
||||
#app.node.toggle-tree #checklist {
|
||||
padding: 16px;
|
||||
}
|
||||
#profile-settings {
|
||||
color: #333;
|
||||
padding: 16px;
|
||||
}
|
||||
#profile-settings .passwords {
|
||||
display: grid;
|
||||
grid-template-columns: min-content 200px;
|
||||
grid-gap: 8px 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
#profile-settings .passwords div {
|
||||
white-space: nowrap;
|
||||
}
|
||||
#schedule-events {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, min-content);
|
||||
grid-gap: 4px 12px;
|
||||
margin: 32px;
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#schedule-events .header {
|
||||
font-weight: bold;
|
||||
}
|
||||
#input-text {
|
||||
border: 1px solid #000 !important;
|
||||
padding: 16px;
|
||||
width: 300px;
|
||||
}
|
||||
#input-text .label {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
#input-text input[type=text] {
|
||||
width: 100%;
|
||||
padding: 4px;
|
||||
}
|
||||
#input-text .buttons {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 64px 64px;
|
||||
grid-gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
#fullcalendar {
|
||||
margin: 32px;
|
||||
color: #444;
|
||||
}
|
||||
.folder .tabs {
|
||||
border-left: 1px solid #888;
|
||||
display: flex;
|
||||
}
|
||||
.folder .tabs .tab {
|
||||
padding: 16px 32px;
|
||||
border-top: 1px solid #888;
|
||||
border-bottom: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
color: #444;
|
||||
background: #eee;
|
||||
cursor: pointer;
|
||||
}
|
||||
.folder .tabs .tab.selected {
|
||||
border-bottom: none;
|
||||
background: #fff;
|
||||
}
|
||||
.folder .tabs .hack {
|
||||
border-bottom: 1px solid #888;
|
||||
width: 100%;
|
||||
}
|
||||
.folder .content {
|
||||
padding-top: 1px;
|
||||
border-left: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
border-bottom: 1px solid #888;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
@media only screen and (max-width: 932px) {
|
||||
#app {
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "files" "blank";
|
||||
#app.node {
|
||||
grid-template-areas: "header" "crumbs" "child-nodes" "name" "content" "checklist" "schedule" "files" "blank";
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* files */ 1fr;
|
||||
grid-template-rows: min-content /* header */ min-content /* crumbs */ min-content /* child-nodes */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
||||
/* blank */
|
||||
}
|
||||
#app #tree {
|
||||
#app.node #tree {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree {
|
||||
#app.node #checklist {
|
||||
padding: 16px;
|
||||
}
|
||||
#app.node.toggle-tree {
|
||||
display: grid;
|
||||
grid-template-areas: "header" "tree";
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: min-content /* header */ 1fr;
|
||||
/* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}
|
||||
#app.toggle-tree #crumbs {
|
||||
#app.node.toggle-tree #crumbs {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree .child-nodes {
|
||||
#app.node.toggle-tree .child-nodes {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree .node-name {
|
||||
#app.node.toggle-tree .node-name {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree .grow-wrap {
|
||||
#app.node.toggle-tree .grow-wrap {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree #file-section {
|
||||
#app.node.toggle-tree #file-section {
|
||||
display: none;
|
||||
}
|
||||
#app.toggle-tree #tree {
|
||||
#app.node.toggle-tree #tree {
|
||||
display: block;
|
||||
}
|
||||
.node-content {
|
||||
|
|
@ -572,7 +879,9 @@ header .menu {
|
|||
padding: 16px;
|
||||
justify-self: start;
|
||||
}
|
||||
#file-section {
|
||||
#file-section,
|
||||
#checklist,
|
||||
#markdown {
|
||||
width: calc(100% - 32px);
|
||||
padding: 16px;
|
||||
margin-left: 16px;
|
||||
|
|
|
|||
29
static/css/search.css
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
@theme_gradient: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
@theme_gradient: linear-gradient(to right, #f5af19, #f12711);
|
||||
@theme_gradient: linear-gradient(to right, #fdc830, #f37335);
|
||||
@theme_gradient: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
@theme_gradient: linear-gradient(to right, #659999, #f4791f);
|
||||
*/
|
||||
#search {
|
||||
padding: 16px;
|
||||
color: #333;
|
||||
}
|
||||
#search h2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
#search input[type=text] {
|
||||
font-size: 1em;
|
||||
}
|
||||
#search button {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
}
|
||||
#search .matches .matched-node {
|
||||
cursor: pointer;
|
||||
margin-top: 6px;
|
||||
}
|
||||
#search .matches .matched-node:before {
|
||||
content: "•";
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
@theme_gradient: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
@theme_gradient: linear-gradient(to right, #f5af19, #f12711);
|
||||
@theme_gradient: linear-gradient(to right, #fdc830, #f37335);
|
||||
@theme_gradient: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
@theme_gradient: linear-gradient(to right, #659999, #f4791f);
|
||||
*/
|
||||
76
static/images/add-gray.svg
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="127.99999"
|
||||
height="127.99999"
|
||||
viewBox="0 0 33.866664 33.866666"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="add-gray.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="28.5"
|
||||
inkscape:cy="32"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1044"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="1096"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d6d6d6"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-57.706364,-79.853668)">
|
||||
<rect
|
||||
style="color:#000000;overflow:visible;fill:#8dd35f;fill-rule:evenodd;stroke-width:3.175;paint-order:markers stroke fill;stop-color:#000000;fill-opacity:1"
|
||||
id="rect232"
|
||||
width="33.866669"
|
||||
height="7.4083333"
|
||||
x="57.706364"
|
||||
y="93.082832" />
|
||||
<rect
|
||||
style="color:#000000;overflow:visible;fill:#8dd35f;fill-rule:evenodd;stroke-width:3.175;paint-order:markers stroke fill;stop-color:#000000;fill-opacity:1"
|
||||
id="rect396"
|
||||
width="33.866665"
|
||||
height="7.4083333"
|
||||
x="79.853668"
|
||||
y="-78.343864"
|
||||
transform="rotate(90)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
71
static/images/checklist-off.svg
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="4.7624998mm"
|
||||
height="5.2916698mm"
|
||||
viewBox="0 0 4.7624996 5.2916701"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="checklist-off.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#0088ff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="9"
|
||||
inkscape:cy="9.5"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1404"
|
||||
inkscape:window-x="1280"
|
||||
inkscape:window-y="16"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-120.36363,-120.48512)">
|
||||
<title
|
||||
id="title1">clipboard-check</title>
|
||||
<title
|
||||
id="title1-7">clipboard-check</title>
|
||||
<title
|
||||
id="title1-5">clipboard-check-outline</title>
|
||||
<path
|
||||
d="m 124.59697,121.01429 h -1.10596 c -0.11113,-0.30692 -0.40217,-0.52917 -0.74613,-0.52917 -0.34395,0 -0.635,0.22225 -0.74612,0.52917 h -1.10596 a 0.52916667,0.52916667 0 0 0 -0.52917,0.52917 v 3.70416 a 0.52916667,0.52916667 0 0 0 0.52917,0.52917 h 3.70417 a 0.52916667,0.52916667 0 0 0 0.52916,-0.52917 v -3.70416 a 0.52916667,0.52916667 0 0 0 -0.52916,-0.52917 m -1.85209,0 a 0.26458333,0.26458333 0 0 1 0.26459,0.26458 0.26458333,0.26458333 0 0 1 -0.26459,0.26459 0.26458333,0.26458333 0 0 1 -0.26458,-0.26459 0.26458333,0.26458333 0 0 1 0.26458,-0.26458 m -1.32291,1.05833 h 2.64583 v -0.52916 h 0.52917 v 3.70416 h -3.70417 v -3.70416 h 0.52917 v 0.52916 m 0.13229,1.7198 0.39687,-0.39688 0.52917,0.52917 1.19063,-1.19063 0.39687,0.39688 -1.5875,1.5875 z"
|
||||
id="path1"
|
||||
style="stroke-width:0.264583;fill:#f9f9f9" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
73
static/images/checklist-on.svg
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="4.7624998mm"
|
||||
height="5.2916698mm"
|
||||
viewBox="0 0 4.7624996 5.2916701"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="checklist-on.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#0088ff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="9"
|
||||
inkscape:cy="9.5"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1404"
|
||||
inkscape:window-x="1280"
|
||||
inkscape:window-y="16"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-120.36363,-120.48512)">
|
||||
<title
|
||||
id="title1">clipboard-check</title>
|
||||
<title
|
||||
id="title1-7">clipboard-check</title>
|
||||
<title
|
||||
id="title1-5">clipboard-check-outline</title>
|
||||
<title
|
||||
id="title1-3">clipboard-check</title>
|
||||
<path
|
||||
d="m 122.21571,124.71846 -1.05833,-1.05834 0.37306,-0.37306 0.68527,0.68263 1.74361,-1.74361 0.37306,0.37571 m -1.5875,-1.5875 a 0.26458333,0.26458333 0 0 1 0.26458,0.26458 0.26458333,0.26458333 0 0 1 -0.26458,0.26459 0.26458333,0.26458333 0 0 1 -0.26458,-0.26459 0.26458333,0.26458333 0 0 1 0.26458,-0.26458 m 1.85208,0 H 123.491 c -0.11112,-0.30692 -0.40216,-0.52917 -0.74612,-0.52917 -0.34396,0 -0.635,0.22225 -0.74613,0.52917 h -1.10595 a 0.52916666,0.52916666 0 0 0 -0.52917,0.52917 v 3.70416 a 0.52916666,0.52916666 0 0 0 0.52917,0.52917 h 3.70416 a 0.52916666,0.52916666 0 0 0 0.52917,-0.52917 v -3.70416 a 0.52916666,0.52916666 0 0 0 -0.52917,-0.52917 z"
|
||||
id="path1"
|
||||
style="stroke-width:0.264583;fill:#f9f9f9" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
66
static/images/edit-list-gray.svg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="19.463146mm"
|
||||
height="14.45555mm"
|
||||
viewBox="0 0 19.463145 14.455551"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="edit.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="34.875"
|
||||
inkscape:cy="63"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1044"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="1096"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-95.481611,-106.78967)">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m 95.481611,106.78967 v 2.06503 h 11.357839 v -2.06503 H 95.481611 m 0,4.13011 v 2.06507 h 11.357839 v -2.06507 H 95.481611 m 17.553019,0.10341 c -0.10342,0 -0.30986,0.10342 -0.41304,0.20644 l -1.03251,1.03256 2.16829,2.16829 1.03255,-1.03252 c 0.20645,-0.20644 0.20645,-0.61951 0,-0.82603 l -1.34229,-1.3423 c -0.10342,-0.10302 -0.20644,-0.20644 -0.413,-0.20644 m -1.96181,1.85855 -6.29844,6.19518 v 2.1683 h 2.16829 l 6.29844,-6.29844 -2.16829,-2.06504 m -15.591209,2.1683 v 2.06507 h 7.227699 v -2.06507 z"
|
||||
id="path1"
|
||||
style="stroke-width:1.03253;fill:#b1b1b1;fill-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
66
static/images/edit-list.svg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="19.463146mm"
|
||||
height="14.45555mm"
|
||||
viewBox="0 0 19.463145 14.455551"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="edit.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="-9.5"
|
||||
inkscape:cy="166"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1044"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="1096"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-95.481611,-106.78967)">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m 95.481611,106.78967 v 2.06503 h 11.357839 v -2.06503 H 95.481611 m 0,4.13011 v 2.06507 h 11.357839 v -2.06507 H 95.481611 m 17.553019,0.10341 c -0.10342,0 -0.30986,0.10342 -0.41304,0.20644 l -1.03251,1.03256 2.16829,2.16829 1.03255,-1.03252 c 0.20645,-0.20644 0.20645,-0.61951 0,-0.82603 l -1.34229,-1.3423 c -0.10342,-0.10302 -0.20644,-0.20644 -0.413,-0.20644 m -1.96181,1.85855 -6.29844,6.19518 v 2.1683 h 2.16829 l 6.29844,-6.29844 -2.16829,-2.06504 m -15.591209,2.1683 v 2.06507 h 7.227699 v -2.06507 z"
|
||||
id="path1"
|
||||
style="stroke-width:1.03253" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
66
static/images/edit.svg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="26.156595mm"
|
||||
height="26.156595mm"
|
||||
viewBox="0 0 26.156594 26.156597"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="edit.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="6.5"
|
||||
inkscape:cy="41"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1044"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="1096"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-103.00032,-112.64716)">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m 128.73192,118.52071 c 0.56666,-0.56666 0.56666,-1.51108 0,-2.04869 l -3.39986,-3.39986 c -0.53761,-0.56666 -1.48203,-0.56666 -2.04869,0 l -2.67339,2.6589 5.44854,5.44849 m -23.0582,12.17566 v 5.44855 h 5.44849 l 16.06958,-16.08408 -5.44854,-5.44855 z"
|
||||
id="path1"
|
||||
style="stroke-width:1.45294;fill:#ff9955;fill-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
49
static/images/markdown-hollow.svg
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
height="128"
|
||||
width="208"
|
||||
viewBox="-31.2 -32 208 128"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="markdown-hollow.svg"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="true"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="5.6568542"
|
||||
inkscape:cx="109.68994"
|
||||
inkscape:cy="68.942911"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1404"
|
||||
inkscape:window-x="1280"
|
||||
inkscape:window-y="16"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<rect
|
||||
fill="none"
|
||||
stroke-width="10"
|
||||
stroke="#000000"
|
||||
ry="10"
|
||||
y="-27"
|
||||
x="-26.200001"
|
||||
height="118"
|
||||
width="198"
|
||||
id="rect1"
|
||||
style="stroke:#ffffff;stroke-opacity:1" />
|
||||
<path
|
||||
d="M -1.2000003,66 V -2 H 18.8 l 20,25 20,-25 h 20 v 68 h -20 V 27 l -20,25 -20,-25 V 66 Z M 123.8,66 93.8,33 h 20 V -2 h 20 v 35 h 20 z"
|
||||
id="path1"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
57
static/images/markdown.svg
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
|
||||
<svg
|
||||
fill="#000000"
|
||||
width="365.05487"
|
||||
height="224.67957"
|
||||
viewBox="0 0 365.05487 224.67956"
|
||||
role="img"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="markdown.svg"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.4827692"
|
||||
inkscape:cx="400.26458"
|
||||
inkscape:cy="394.53206"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1404"
|
||||
inkscape:window-x="1280"
|
||||
inkscape:window-y="16"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg1" />
|
||||
<title
|
||||
id="title1">Markdown icon</title>
|
||||
<path
|
||||
d="M 338.73829,224.67957 H 26.316564 A 26.316564,26.316564 0 0 1 0,198.363 V 26.316564 A 26.316564,26.316564 0 0 1 26.316564,0 H 338.73829 a 26.316564,26.316564 0 0 1 26.31657,26.316564 V 198.33258 a 26.316564,26.316564 0 0 1 -26.31657,26.33177 z M 87.742162,172.01601 v -68.45349 l 35.109038,43.8863 35.09382,-43.8863 v 68.45349 h 35.10903 V 52.678763 H 157.94502 L 122.8512,96.565057 87.742162,52.678763 H 52.633128 V 172.04644 Z M 322.94835,112.33978 H 287.83932 V 52.663552 H 252.7455 v 59.676228 h -35.10904 l 52.64834,61.44081 z"
|
||||
id="path1"
|
||||
style="stroke-width:15.2119;fill:#ffffff;fill-opacity:1" />
|
||||
<metadata
|
||||
id="metadata1">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:title>Markdown icon</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
107
static/images/search.svg
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="191.20831"
|
||||
height="227.46098"
|
||||
viewBox="0 0 50.590532 60.182387"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.2.1 (9c6d41e, 2022-07-14)"
|
||||
sodipodi:docname="search.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient16049">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.36503741;"
|
||||
offset="0"
|
||||
id="stop16045" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop16047" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient16049"
|
||||
id="linearGradient16051"
|
||||
x1="36.007183"
|
||||
y1="8.6465521"
|
||||
x2="12.402377"
|
||||
y2="41.804993"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#5056d3"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="153.08862"
|
||||
inkscape:cy="145.664"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="2190"
|
||||
inkscape:window-height="1404"
|
||||
inkscape:window-x="1463"
|
||||
inkscape:window-y="16"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d6d6d6"
|
||||
showborder="true"
|
||||
showguides="false">
|
||||
<sodipodi:guide
|
||||
position="57.608417,-11.948636"
|
||||
orientation="0.81915204,0.57357644"
|
||||
id="guide5717"
|
||||
inkscape:locked="false"
|
||||
inkscape:label=""
|
||||
inkscape:color="rgb(0,134,229)" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-2.3771159,-1.8407145)">
|
||||
<path
|
||||
style="color:#000000;overflow:visible;opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:8.46667;stroke-linecap:round;stroke-dasharray:none;paint-order:markers stroke fill;stop-color:#000000"
|
||||
d="m 38.808695,43.970762 9.925619,13.819002"
|
||||
id="path2090" />
|
||||
<path
|
||||
id="circle4774"
|
||||
style="color:#000000;overflow:visible;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.175;paint-order:markers stroke fill;stop-color:#000000"
|
||||
d="M 25.660449,1.8407145 A 23.283335,23.283335 0 0 0 2.3771159,25.124048 23.283335,23.283335 0 0 0 25.660449,48.407381 23.283335,23.283335 0 0 0 48.944299,25.124048 23.283335,23.283335 0 0 0 25.660449,1.8407145 Z m 0,6.35 A 16.933332,16.933332 0 0 1 42.593783,25.124048 16.933332,16.933332 0 0 1 25.660449,42.057381 16.933332,16.933332 0 0 1 8.7276327,25.124048 16.933332,16.933332 0 0 1 25.660449,8.1907145 Z" />
|
||||
<circle
|
||||
style="color:#000000;overflow:visible;fill:url(#linearGradient16051);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.175;paint-order:markers stroke fill;stop-color:#000000"
|
||||
id="path429"
|
||||
cx="25.660707"
|
||||
cy="25.123877"
|
||||
r="16.933332" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
66
static/images/trashcan.svg
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="23.835697mm"
|
||||
height="26.815161mm"
|
||||
viewBox="0 0 23.835696 26.815162"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
|
||||
sodipodi:docname="trashcan.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="45.5"
|
||||
inkscape:cy="51"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1916"
|
||||
inkscape:window-height="1044"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="1096"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:showpageshadow="true"
|
||||
inkscape:pagecheckerboard="false"
|
||||
inkscape:deskcolor="#dddddd"
|
||||
showborder="true" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-81.215483,-137.6695)">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m 88.66414,137.6695 v 1.48977 h -7.448657 v 2.97942 h 1.489734 v 19.36654 a 2.9794621,2.9794621 0 0 0 2.979459,2.97943 h 14.897314 a 2.9794621,2.9794621 0 0 0 2.97946,-2.97943 v -19.36654 h 1.48973 v -2.97942 H 97.602526 V 137.6695 H 88.66414 m -2.979464,4.46919 h 14.897314 v 19.36654 H 85.684676 v -19.36654 m 2.979464,2.97948 v 13.40758 h 2.979464 V 145.11817 H 88.66414 m 5.958922,0 v 13.40758 h 2.979464 v -13.40758 z"
|
||||
id="path1"
|
||||
style="stroke-width:1.48973;fill:#d35f5f" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
|
|
@ -5,6 +5,7 @@
|
|||
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/main.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/login.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/search.css">
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
|
|
@ -18,12 +19,15 @@
|
|||
"session": "/js/{{ .VERSION }}/session.mjs",
|
||||
"node": "/js/{{ .VERSION }}/node.mjs",
|
||||
"key": "/js/{{ .VERSION }}/key.mjs",
|
||||
"crypto": "/js/{{ .VERSION }}/crypto.mjs"
|
||||
"crypto": "/js/{{ .VERSION }}/crypto.mjs",
|
||||
"checklist": "/js/{{ .VERSION }}/checklist.mjs",
|
||||
"ws": "/_js/{{ .VERSION }}/websocket.mjs"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/sjcl.js"></script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/css_reload.js"></script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/node_modules/marked/marked.min.js"></script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/fullcalendar.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,17 @@
|
|||
import 'preact/debug'
|
||||
import 'preact/devtools'
|
||||
import { signal } from 'preact/signals'
|
||||
|
||||
import { h, Component, render, createRef } from 'preact'
|
||||
import htm from 'htm'
|
||||
import { Session } from 'session'
|
||||
import { Node, NodeUI } from 'node'
|
||||
import { Websocket } from 'ws'
|
||||
import { signal } from 'preact/signals'
|
||||
const html = htm.bind(h)
|
||||
|
||||
class App extends Component {
|
||||
constructor() {//{{{
|
||||
super()
|
||||
this.websocket_uri = `ws://localhost:1371/ws`
|
||||
this.websocket = null
|
||||
this.websocket_int_ping = null
|
||||
this.websocket_int_reconnect = null
|
||||
this.wsConnect()
|
||||
this.wsLoop()
|
||||
|
||||
this.session = new Session(this)
|
||||
this.session.initialize()
|
||||
|
|
@ -25,117 +22,106 @@ class App extends Component {
|
|||
|
||||
this.startNode = null
|
||||
|
||||
this.websocketInit()
|
||||
this.setStartNode()
|
||||
}//}}}
|
||||
render() {//{{{
|
||||
if(!this.session.initialized) {
|
||||
return html`<div>Validating session</div>`
|
||||
let app_el = document.getElementById('app')
|
||||
|
||||
if (!this.session.initialized) {
|
||||
return
|
||||
}
|
||||
|
||||
if(!this.session.authenticated()) {
|
||||
|
||||
if (!this.session.authenticated()) {
|
||||
app_el.classList.remove('node')
|
||||
app_el.classList.add('login')
|
||||
return html`<${Login} ref=${this.login} />`
|
||||
}
|
||||
|
||||
app_el.classList.remove('login')
|
||||
app_el.classList.add('node')
|
||||
return html`
|
||||
<${Tree} app=${this} ref=${this.tree} />
|
||||
<${NodeUI} app=${this} ref=${this.nodeUI} />
|
||||
`
|
||||
}//}}}
|
||||
|
||||
wsLoop() {//{{{
|
||||
setInterval(()=>{
|
||||
if(this.websocket === null) {
|
||||
console.log("wsLoop connect")
|
||||
this.wsConnect()
|
||||
}
|
||||
}, 1000)
|
||||
}//}}}
|
||||
wsConnect() {//{{{
|
||||
this.websocket = new WebSocket(this.websocket_uri)
|
||||
this.websocket.onopen = evt=>this.wsOpen(evt)
|
||||
this.websocket.onmessage = evt=>this.wsMessage(evt)
|
||||
this.websocket.onerror = evt=>this.wsError(evt)
|
||||
this.websocket.onclose = evt=>this.wsClose(evt)
|
||||
}//}}}
|
||||
wsOpen() {//{{{
|
||||
this.setState({ wsConnected: true })
|
||||
|
||||
// A ping interval to implement a rudimentary keep-alive.
|
||||
}//}}}
|
||||
wsClose() {//{{{
|
||||
console.log("Lost connection to Notes server")
|
||||
this.websocket = null
|
||||
}//}}}
|
||||
wsError(evt) {//{{{
|
||||
console.log("websocket error", evt)
|
||||
this.websocket = null;
|
||||
}//}}}
|
||||
wsMessage(evt) {//{{{
|
||||
let msg = JSON.parse(evt.data)
|
||||
|
||||
// Broadcast message
|
||||
if(msg.ID == '') {
|
||||
this.broadcastHandler(msg)
|
||||
} else {
|
||||
this.msgHandler(msg)
|
||||
}
|
||||
}//}}}
|
||||
|
||||
responseError({comm, app, upload}) {//{{{
|
||||
if(comm !== undefined) {
|
||||
comm.text().then(body=>alert(body))
|
||||
responseError({ comm, app, upload }) {//{{{
|
||||
if (comm !== undefined) {
|
||||
if (typeof comm.text === 'function')
|
||||
comm.text().then(body => alert(body))
|
||||
else
|
||||
alert(comm)
|
||||
return
|
||||
}
|
||||
|
||||
if(app !== undefined && app.hasOwnProperty('Error')) {
|
||||
if (app !== undefined && app.hasOwnProperty('Error')) {
|
||||
alert(app.Error)
|
||||
return
|
||||
}
|
||||
|
||||
if(app !== undefined) {
|
||||
if (app !== undefined) {
|
||||
alert(JSON.stringify(app))
|
||||
}
|
||||
|
||||
if(upload !== undefined) {
|
||||
if (upload !== undefined) {
|
||||
alert(upload)
|
||||
return
|
||||
}
|
||||
}//}}}
|
||||
async request(url, params) {//{{{
|
||||
return new Promise((resolve, reject)=>{
|
||||
return new Promise((resolve, reject) => {
|
||||
let headers = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
if(this.session.UUID !== '')
|
||||
headers['X-Session-Id'] = this.session.UUID
|
||||
if (this.session.UUID !== '')
|
||||
headers['X-Session-ID'] = this.session.UUID
|
||||
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify(params),
|
||||
})
|
||||
.then(response=>{
|
||||
// A HTTP communication level error occured
|
||||
if(!response.ok || response.status != 200)
|
||||
return reject({comm: response})
|
||||
return response.json()
|
||||
})
|
||||
.then(json=>{
|
||||
// An application level error occured
|
||||
if(!json.OK) {
|
||||
return reject({app: json})
|
||||
}
|
||||
return resolve(json)
|
||||
})
|
||||
.catch(err=>reject({comm: err}))
|
||||
.then(response => {
|
||||
// A HTTP communication level error occured
|
||||
if (!response.ok || response.status != 200)
|
||||
return reject({ comm: response })
|
||||
return response.json()
|
||||
})
|
||||
.then(json => {
|
||||
// An application level error occured
|
||||
if (!json.OK) {
|
||||
switch (json.Code) {
|
||||
case '001-0001': // Session not found
|
||||
this.session.reset()
|
||||
location.href = '/'
|
||||
break
|
||||
|
||||
default:
|
||||
return reject({ app: json })
|
||||
}
|
||||
}
|
||||
return resolve(json)
|
||||
})
|
||||
.catch(err => reject({ comm: err }))
|
||||
})
|
||||
}//}}}
|
||||
|
||||
broadcastHandler(msg) {//{{{
|
||||
switch(msg.Op) {
|
||||
websocketInit() {//{{{
|
||||
this.websocket = new Websocket()
|
||||
this.websocket.register('open', ()=>console.log('websocket connected'))
|
||||
this.websocket.register('close', ()=>console.log('websocket disconnected'))
|
||||
this.websocket.register('error', msg=>console.log(msg))
|
||||
this.websocket.register('message', msg=>this.websocketMessage(msg))
|
||||
this.websocket.start()
|
||||
}//}}}
|
||||
websocketMessage(data) {//{{{
|
||||
const msg = JSON.parse(data)
|
||||
|
||||
switch (msg.Op) {
|
||||
case 'css_reload':
|
||||
refreshCSS()
|
||||
this.websocket.refreshCSS()
|
||||
break;
|
||||
}
|
||||
}//}}}
|
||||
|
|
@ -155,18 +141,23 @@ class Login extends Component {
|
|||
password: '',
|
||||
}
|
||||
}//}}}
|
||||
render({}, { username, password }) {//{{{
|
||||
render({ }, { username, password }) {//{{{
|
||||
let authentication_failed = html``;
|
||||
if(this.authentication_failed.value)
|
||||
if (this.authentication_failed.value)
|
||||
authentication_failed = html`<div class="auth-failed">Authentication failed</div>`;
|
||||
|
||||
return html`
|
||||
<div id="login">
|
||||
<h1>Notes</h1>
|
||||
<input id="username" type="text" placeholder="Username" value=${username} oninput=${evt=>this.setState({ username: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
|
||||
<input id="password" type="password" placeholder="Password" value=${password} oninput=${evt=>this.setState({ password: evt.target.value})} onkeydown=${evt=>{ if(evt.code == 'Enter') this.login() }} />
|
||||
<button onclick=${()=>this.login()}>Login</button>
|
||||
${authentication_failed}
|
||||
<div class="header">
|
||||
<h1>Notes</h1>
|
||||
</div>
|
||||
|
||||
<div class="fields">
|
||||
<input id="username" type="text" placeholder="Username" value=${username} oninput=${evt => this.setState({ username: evt.target.value })} onkeydown=${evt => { if (evt.code == 'Enter') this.login() }} />
|
||||
<input id="password" type="password" placeholder="Password" value=${password} oninput=${evt => this.setState({ password: evt.target.value })} onkeydown=${evt => { if (evt.code == 'Enter') this.login() }} />
|
||||
<button onclick=${() => this.login()}>Login</button>
|
||||
${authentication_failed}
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}//}}}
|
||||
|
|
@ -190,77 +181,99 @@ class Tree extends Component {
|
|||
this.selectedTreeNode = null
|
||||
|
||||
this.props.app.tree = this
|
||||
|
||||
this.props.app.request('/node/tree', { StartNodeID: 0 })
|
||||
.then(res=>{
|
||||
// A tree of nodes is built. This requires the list of nodes
|
||||
// returned from the server to be sorted in such a way that
|
||||
// a parent node always appears before a child node.
|
||||
// The server uses a recursive SQL query delivering this.
|
||||
res.Nodes.forEach(nodeData=>{
|
||||
let node = new Node(
|
||||
this,
|
||||
nodeData.ID,
|
||||
)
|
||||
node.Children = []
|
||||
node.Crumbs = []
|
||||
node.Files = []
|
||||
node.Level = nodeData.Level
|
||||
node.Name = nodeData.Name
|
||||
node.ParentID = nodeData.ParentID
|
||||
node.Updated = nodeData.Updated
|
||||
node.UserID = nodeData.UserID
|
||||
|
||||
this.treeNodes[node.ID] = node
|
||||
|
||||
if(node.ParentID == 0)
|
||||
this.treeTrunk.push(node)
|
||||
else if(this.treeNodes[node.ParentID] !== undefined)
|
||||
this.treeNodes[node.ParentID].Children.push(node)
|
||||
})
|
||||
// When starting with an explicit node value, expanding all nodes
|
||||
// on its path gives the user a sense of location. Not necessarily working
|
||||
// as the start node isn't guaranteed to have returned data yet.
|
||||
this.crumbsUpdateNodes()
|
||||
this.forceUpdate()
|
||||
|
||||
})
|
||||
.catch(this.responseError)
|
||||
this.retrieve()
|
||||
}//}}}
|
||||
render({ app }) {//{{{
|
||||
let renderedTreeTrunk = this.treeTrunk.map(node=>{
|
||||
let renderedTreeTrunk = this.treeTrunk.map(node => {
|
||||
this.treeNodeComponents[node.ID] = createRef()
|
||||
return html`<${TreeNode} key=${"treenode_"+node.ID} tree=${this} node=${node} ref=${this.treeNodeComponents[node.ID]} selected=${node.ID == app.startNode.ID} />`
|
||||
return html`<${TreeNode} key=${"treenode_" + node.ID} tree=${this} node=${node} ref=${this.treeNodeComponents[node.ID]} selected=${node.ID == app.startNode.ID} />`
|
||||
})
|
||||
return html`<div id="tree">${renderedTreeTrunk}</div>`
|
||||
}//}}}
|
||||
|
||||
retrieve(callback = null) {//{{{
|
||||
this.props.app.request('/node/tree', { StartNodeID: 0 })
|
||||
.then(res => {
|
||||
this.treeNodes = {}
|
||||
this.treeNodeComponents = {}
|
||||
this.treeTrunk = []
|
||||
this.selectedTreeNode = null
|
||||
|
||||
// A tree of nodes is built. This requires the list of nodes
|
||||
// returned from the server to be sorted in such a way that
|
||||
// a parent node always appears before a child node.
|
||||
// The server uses a recursive SQL query delivering this.
|
||||
res.Nodes.forEach(nodeData => {
|
||||
let node = new Node(
|
||||
this,
|
||||
nodeData.ID,
|
||||
)
|
||||
node.Children = []
|
||||
node.Crumbs = []
|
||||
node.Files = []
|
||||
node.Level = nodeData.Level
|
||||
node.Name = nodeData.Name
|
||||
node.ParentID = nodeData.ParentID
|
||||
node.Updated = nodeData.Updated
|
||||
node.UserID = nodeData.UserID
|
||||
|
||||
this.treeNodes[node.ID] = node
|
||||
|
||||
if (node.ParentID == 0)
|
||||
this.treeTrunk.push(node)
|
||||
else if (this.treeNodes[node.ParentID] !== undefined)
|
||||
this.treeNodes[node.ParentID].Children.push(node)
|
||||
})
|
||||
// When starting with an explicit node value, expanding all nodes
|
||||
// on its path gives the user a sense of location. Not necessarily working
|
||||
// as the start node isn't guaranteed to have returned data yet.
|
||||
this.crumbsUpdateNodes()
|
||||
this.forceUpdate()
|
||||
|
||||
if (callback)
|
||||
callback()
|
||||
|
||||
})
|
||||
.catch(this.responseError)
|
||||
}//}}}
|
||||
setSelected(node) {//{{{
|
||||
if(this.selectedTreeNode)
|
||||
if (this.selectedTreeNode)
|
||||
this.selectedTreeNode.selected.value = false
|
||||
|
||||
this.selectedTreeNode = this.treeNodeComponents[node.ID].current
|
||||
this.selectedTreeNode.selected.value = true
|
||||
this.selectedTreeNode.expanded.value = true
|
||||
this.expandToTrunk(node.ID)
|
||||
}//}}}
|
||||
crumbsUpdateNodes(node) {//{{{
|
||||
this.props.app.startNode.Crumbs.forEach(crumb=>{
|
||||
this.props.app.startNode.Crumbs.forEach(crumb => {
|
||||
// Start node is loaded before the tree.
|
||||
let node = this.treeNodes[crumb.ID]
|
||||
if(node)
|
||||
if (node)
|
||||
node._expanded = true
|
||||
|
||||
// Tree is done before the start node.
|
||||
let component = this.treeNodeComponents[crumb.ID]
|
||||
if(component && component.current)
|
||||
if (component && component.current)
|
||||
component.current.expanded.value = true
|
||||
})
|
||||
|
||||
// Will be undefined when called from tree initialization
|
||||
// (as tree nodes aren't rendered yet)
|
||||
if(node !== undefined)
|
||||
if (node !== undefined)
|
||||
this.setSelected(node)
|
||||
}//}}}
|
||||
expandToTrunk(nodeID) {//{{{
|
||||
let node = this.treeNodes[nodeID]
|
||||
if (node === undefined)
|
||||
return
|
||||
|
||||
node = this.treeNodes[node.ParentID]
|
||||
while (node !== undefined) {
|
||||
this.treeNodeComponents[node.ID].current.expanded.value = true
|
||||
node = this.treeNodes[node.ParentID]
|
||||
}
|
||||
}//}}}
|
||||
}
|
||||
|
||||
class TreeNode extends Component {
|
||||
|
|
@ -271,16 +284,16 @@ class TreeNode extends Component {
|
|||
}//}}}
|
||||
render({ tree, node }) {//{{{
|
||||
|
||||
let children = node.Children.map(node=>{
|
||||
let children = node.Children.map(node => {
|
||||
tree.treeNodeComponents[node.ID] = createRef()
|
||||
return html`<${TreeNode} key=${"treenode_"+node.ID} tree=${tree} node=${node} ref=${tree.treeNodeComponents[node.ID]} selected=${node.ID == tree.props.app.startNode.ID} />`
|
||||
return html`<${TreeNode} key=${"treenode_" + node.ID} tree=${tree} node=${node} ref=${tree.treeNodeComponents[node.ID]} selected=${node.ID == tree.props.app.startNode.ID} />`
|
||||
})
|
||||
|
||||
let expandImg = ''
|
||||
if(node.Children.length == 0)
|
||||
if (node.Children.length == 0)
|
||||
expandImg = html`<img src="/images/${window._VERSION}/leaf.svg" />`
|
||||
else {
|
||||
if(this.expanded.value)
|
||||
if (this.expanded.value)
|
||||
expandImg = html`<img src="/images/${window._VERSION}/expanded.svg" />`
|
||||
else
|
||||
expandImg = html`<img src="/images/${window._VERSION}/collapsed.svg" />`
|
||||
|
|
@ -291,8 +304,8 @@ class TreeNode extends Component {
|
|||
|
||||
return html`
|
||||
<div class="node">
|
||||
<div class="expand-toggle" onclick=${()=>this.expanded.value ^= true}>${expandImg}</div>
|
||||
<div class="name ${selected}" onclick=${()=>window._app.current.nodeUI.current.goToNode(node.ID)}>${node.Name}</div>
|
||||
<div class="expand-toggle" onclick=${() => this.expanded.value ^= true}>${expandImg}</div>
|
||||
<div class="name ${selected}" onclick=${() => window._app.current.nodeUI.current.goToNode(node.ID)}>${node.Name}</div>
|
||||
<div class="children ${node.Children.length > 0 && this.expanded.value ? 'expanded' : 'collapsed'}">${children}</div>
|
||||
</div>`
|
||||
}//}}}
|
||||
|
|
|
|||
472
static/js/checklist.mjs
Normal file
|
|
@ -0,0 +1,472 @@
|
|||
import { h, Component, createRef } from 'preact'
|
||||
import htm from 'htm'
|
||||
import { signal } from 'preact/signals'
|
||||
const html = htm.bind(h)
|
||||
|
||||
export class ChecklistGroup {
|
||||
static sort(a, b) {//{{{
|
||||
if (a.Order < b.Order) return -1
|
||||
if (a.Order > b.Order) return 1
|
||||
return 0
|
||||
}//}}}
|
||||
constructor(data) {//{{{
|
||||
Object.keys(data).forEach(key => {
|
||||
if (key == 'Items')
|
||||
this.items = data[key].map(itemData => {
|
||||
let item = new ChecklistItem(itemData)
|
||||
item.checklistGroup = this
|
||||
return item
|
||||
})
|
||||
else
|
||||
this[key] = data[key]
|
||||
})
|
||||
}//}}}
|
||||
addItem(label, okCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_group/item_add', {
|
||||
ChecklistGroupID: this.ID,
|
||||
Label: label,
|
||||
})
|
||||
.then(json => {
|
||||
let item = new ChecklistItem(json.Item)
|
||||
item.checklistGroup = this
|
||||
this.items.push(item)
|
||||
okCallback()
|
||||
})
|
||||
.catch(window._app.current.responseError)
|
||||
return
|
||||
}//}}}
|
||||
updateLabel(newLabel, okCallback, errCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_group/label', {
|
||||
ChecklistGroupID: this.ID,
|
||||
Label: newLabel,
|
||||
})
|
||||
.then(okCallback)
|
||||
.catch(errCallback)
|
||||
}//}}}
|
||||
delete(okCallback, errCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_group/delete', {
|
||||
ChecklistGroupID: this.ID,
|
||||
})
|
||||
.then(() => {
|
||||
okCallback()
|
||||
})
|
||||
.catch(errCallback)
|
||||
}//}}}
|
||||
}
|
||||
|
||||
export class ChecklistItem {
|
||||
static sort(a, b) {//{{{
|
||||
if (a.Order < b.Order) return -1
|
||||
if (a.Order > b.Order) return 1
|
||||
return 0
|
||||
}//}}}
|
||||
constructor(data) {//{{{
|
||||
Object.keys(data).forEach(key => {
|
||||
this[key] = data[key]
|
||||
})
|
||||
}//}}}
|
||||
updateState(newState, okCallback, errCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_item/state', {
|
||||
ChecklistItemID: this.ID,
|
||||
State: newState,
|
||||
})
|
||||
.then(okCallback)
|
||||
.catch(errCallback)
|
||||
}//}}}
|
||||
updateLabel(newLabel, okCallback, errCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_item/label', {
|
||||
ChecklistItemID: this.ID,
|
||||
Label: newLabel,
|
||||
})
|
||||
.then(okCallback)
|
||||
.catch(errCallback)
|
||||
}//}}}
|
||||
delete(okCallback, errCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_item/delete', {
|
||||
ChecklistItemID: this.ID,
|
||||
})
|
||||
.then(() => {
|
||||
this.checklistGroup.items = this.checklistGroup.items.filter(item => item.ID != this.ID)
|
||||
okCallback()
|
||||
})
|
||||
.catch(errCallback)
|
||||
}//}}}
|
||||
move(to, okCallback) {//{{{
|
||||
window._app.current.request('/node/checklist_item/move', {
|
||||
ChecklistItemID: this.ID,
|
||||
AfterItemID: to.ID,
|
||||
})
|
||||
.then(okCallback)
|
||||
.catch(_app.current.responseError)
|
||||
}//}}}
|
||||
}
|
||||
|
||||
export class Checklist extends Component {
|
||||
constructor() {//{{{
|
||||
super()
|
||||
this.edit = signal(false)
|
||||
this.dragItemSource = null
|
||||
this.dragItemTarget = null
|
||||
this.groupElements = {}
|
||||
this.state = {
|
||||
confirmDeletion: true,
|
||||
continueAddingItems: true,
|
||||
}
|
||||
window._checklist = this
|
||||
}//}}}
|
||||
render({ ui, groups }, { confirmDeletion, continueAddingItems }) {//{{{
|
||||
this.groupElements = {}
|
||||
if (groups.length == 0 && !ui.node.value.ShowChecklist.value)
|
||||
return
|
||||
|
||||
if (typeof groups.sort != 'function')
|
||||
groups = []
|
||||
|
||||
groups.sort(ChecklistGroup.sort)
|
||||
let groupElements = groups.map(group => {
|
||||
this.groupElements[group.ID] = createRef()
|
||||
return html`<${ChecklistGroupElement} ref=${this.groupElements[group.ID]} key="group-${group.ID}" ui=${this} group=${group} />`
|
||||
})
|
||||
|
||||
let edit = 'edit-list-gray.svg'
|
||||
let confirmDeletionEl = ''
|
||||
if (this.edit.value) {
|
||||
edit = 'edit-list.svg'
|
||||
confirmDeletionEl = html`
|
||||
<div>
|
||||
<input type="checkbox" id="confirm-checklist-delete" checked=${confirmDeletion} onchange=${() => this.setState({ confirmDeletion: !confirmDeletion })} />
|
||||
<label for="confirm-checklist-delete">Confirm checklist deletion</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="continue-adding-items" checked=${continueAddingItems} onchange=${() => this.setState({ continueAddingItems: !continueAddingItems })} />
|
||||
<label for="continue-adding-items">Continue adding items</label>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
let addGroup = () => {
|
||||
if (this.edit.value)
|
||||
return html`<img src="/images/${_VERSION}/add-gray.svg" onclick=${() => this.addGroup()} />`
|
||||
}
|
||||
|
||||
return html`
|
||||
<div id="checklist">
|
||||
<div class="header">
|
||||
<h1>Checklist</h1>
|
||||
<img src="/images/${_VERSION}/${edit}" onclick=${() => this.toggleEdit()} />
|
||||
<${addGroup} />
|
||||
</div>
|
||||
${confirmDeletionEl}
|
||||
${groupElements}
|
||||
</div>
|
||||
`
|
||||
}//}}}
|
||||
|
||||
toggleEdit() {//{{{
|
||||
this.edit.value = !this.edit.value
|
||||
}//}}}
|
||||
addGroup() {//{{{
|
||||
let label = prompt("Create a new group")
|
||||
if (label === null)
|
||||
return
|
||||
label = label.trim()
|
||||
if (label == '')
|
||||
return
|
||||
|
||||
window._app.current.request('/node/checklist_group/add', {
|
||||
NodeID: window._app.current.nodeUI.current.node.value.ID,
|
||||
Label: label,
|
||||
})
|
||||
.then(json => {
|
||||
let group = new ChecklistGroup(json.Group)
|
||||
this.props.groups.push(group)
|
||||
this.forceUpdate()
|
||||
})
|
||||
.catch(window._app.current.responseError)
|
||||
return
|
||||
}//}}}
|
||||
dragTarget(target) {//{{{
|
||||
if (this.dragItemTarget)
|
||||
this.dragItemTarget.setDragTarget(false)
|
||||
this.dragItemTarget = target
|
||||
target.setDragTarget(true)
|
||||
}//}}}
|
||||
dragReset() {//{{{
|
||||
if (this.dragItemTarget) {
|
||||
this.dragItemTarget.setDragTarget(false)
|
||||
this.dragItemTarget = null
|
||||
}
|
||||
}//}}}
|
||||
}
|
||||
|
||||
class InputElement extends Component {
|
||||
render({ placeholder, label }) {//{{{
|
||||
return html`
|
||||
<dialog id="input-text">
|
||||
<div class="container">
|
||||
<div class="label">${label}</div>
|
||||
<input id="input-text-el" type="text" placeholder=${placeholder} />
|
||||
<div class="buttons">
|
||||
<div></div>
|
||||
<button onclick=${()=>this.cancel()}>Cancel</button>
|
||||
<button onclick=${()=>this.ok()}>OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
`
|
||||
}//}}}
|
||||
componentDidMount() {//{{{
|
||||
const dlg = document.getElementById('input-text')
|
||||
const input = document.getElementById('input-text-el')
|
||||
dlg.showModal()
|
||||
dlg.addEventListener("keydown", evt => this.keyhandler(evt))
|
||||
input.addEventListener("keydown", evt => this.keyhandler(evt))
|
||||
input.focus()
|
||||
}//}}}
|
||||
ok() {//{{{
|
||||
const input = document.getElementById('input-text-el')
|
||||
this.props.callback(true, input.value)
|
||||
}//}}}
|
||||
cancel() {//{{{
|
||||
this.props.callback(false)
|
||||
}//}}}
|
||||
keyhandler(evt) {//{{{
|
||||
let handled = true
|
||||
switch (evt.key) {
|
||||
case 'Enter':
|
||||
this.ok()
|
||||
break;
|
||||
|
||||
case 'Escape':
|
||||
this.cancel()
|
||||
break;
|
||||
default:
|
||||
handled = false
|
||||
}
|
||||
if (handled) {
|
||||
evt.stopPropagation()
|
||||
evt.preventDefault()
|
||||
}
|
||||
}//}}}
|
||||
}
|
||||
|
||||
class ChecklistGroupElement extends Component {
|
||||
constructor() {//{{{
|
||||
super()
|
||||
this.label = createRef()
|
||||
this.addingItem = signal(false)
|
||||
}//}}}
|
||||
render({ ui, group }) {//{{{
|
||||
let items = ({ ui, group }) =>
|
||||
group.items
|
||||
.sort(ChecklistItem.sort)
|
||||
.map(item => html`<${ChecklistItemElement} key="item-${item.ID}" ui=${ui} group=${this} item=${item} />`)
|
||||
|
||||
let label = () => html`<div class="label" style="cursor: pointer" ref=${this.label} onclick=${() => this.editLabel()}>${group.Label}</div>`
|
||||
let addItem = () => {
|
||||
if (this.addingItem.value)
|
||||
return html`<${InputElement} label="New item" callback=${(ok, val) => this.addItem(ok, val)} />`
|
||||
}
|
||||
|
||||
return html`
|
||||
<${addItem} />
|
||||
<div class="checklist-group-container">
|
||||
<div class="checklist-group ${ui.edit.value ? 'edit' : ''}">
|
||||
<div class="reorder" style="cursor: grab">☰</div>
|
||||
<img src="/images/${_VERSION}/trashcan.svg" onclick=${() => this.delete()} />
|
||||
<${label} />
|
||||
<img src="/images/${_VERSION}/add-gray.svg" onclick=${() => this.addingItem.value = true} />
|
||||
</div>
|
||||
<${items} ui=${ui} group=${group} />
|
||||
</div>
|
||||
`
|
||||
}//}}}
|
||||
addItem(ok, label) {//{{{
|
||||
if (!ok) {
|
||||
this.addingItem.value = false
|
||||
return
|
||||
}
|
||||
|
||||
label = label.trim()
|
||||
if (label == '') {
|
||||
this.addingItem.value = false
|
||||
return
|
||||
}
|
||||
|
||||
this.props.group.addItem(label, () => {
|
||||
this.forceUpdate()
|
||||
})
|
||||
|
||||
if (!this.props.ui.state.continueAddingItems)
|
||||
this.addingItem.value = false
|
||||
}//}}}
|
||||
editLabel() {//{{{
|
||||
let label = prompt('Edit label', this.props.group.Label)
|
||||
if (label === null)
|
||||
return
|
||||
|
||||
label = label.trim()
|
||||
if (label == '') {
|
||||
alert(`A label can't be empty.`)
|
||||
return
|
||||
}
|
||||
|
||||
this.label.current.classList.remove('error')
|
||||
this.props.group.updateLabel(label, () => {
|
||||
this.props.group.Label = label
|
||||
this.label.current.innerHTML = label
|
||||
this.label.current.classList.add('ok')
|
||||
this.forceUpdate()
|
||||
setTimeout(() => this.label.current.classList.remove('ok'), 500)
|
||||
}, () => {
|
||||
this.label.current.classList.add('error')
|
||||
})
|
||||
|
||||
}//}}}
|
||||
delete() {//{{{
|
||||
if (this.props.ui.state.confirmDeletion) {
|
||||
if (!confirm(`Delete '${this.props.group.Label}'?`))
|
||||
return
|
||||
}
|
||||
|
||||
this.props.group.delete(() => {
|
||||
this.props.ui.props.groups = this.props.ui.props.groups.filter(g => g.ID != this.props.group.ID)
|
||||
this.props.ui.forceUpdate()
|
||||
}, err => {
|
||||
console.log(err)
|
||||
console.log('error')
|
||||
})
|
||||
}//}}}
|
||||
}
|
||||
|
||||
class ChecklistItemElement extends Component {
|
||||
constructor(props) {//{{{
|
||||
super(props)
|
||||
this.state = {
|
||||
checked: props.item.Checked,
|
||||
dragTarget: false,
|
||||
}
|
||||
this.checkbox = createRef()
|
||||
this.label = createRef()
|
||||
}//}}}
|
||||
render({ ui, item }, { checked, dragTarget }) {//{{{
|
||||
let checkbox = () => {
|
||||
if (ui.edit.value)
|
||||
return html`<label ref=${this.label} onclick=${() => this.editLabel()} style="cursor: pointer">${item.Label}</label>`
|
||||
else
|
||||
return html`
|
||||
<input type="checkbox" ref=${this.checkbox} key="checkbox-${item.ID}" id="checkbox-${item.ID}" checked=${checked} onchange=${evt => this.update(evt.target.checked)} />
|
||||
<label ref=${this.label} for="checkbox-${item.ID}">${item.Label}</label>
|
||||
`
|
||||
}
|
||||
return html`
|
||||
<div class="checklist-item ${checked ? 'checked' : ''} ${ui.edit.value ? 'edit' : ''} ${dragTarget ? 'drag-target' : ''}" draggable=true>
|
||||
<div class="reorder" style="user-select: none;">☰</div>
|
||||
<img src="/images/${_VERSION}/trashcan.svg" onclick=${() => this.delete()} />
|
||||
<${checkbox} />
|
||||
</div>
|
||||
`
|
||||
}//}}}
|
||||
componentDidMount() {//{{{
|
||||
this.base.addEventListener('dragstart', evt => this.dragStart(evt))
|
||||
this.base.addEventListener('dragend', () => this.dragEnd())
|
||||
this.base.addEventListener('dragenter', evt => this.dragEnter(evt))
|
||||
}//}}}
|
||||
|
||||
update(checked) {//{{{
|
||||
this.setState({ checked })
|
||||
this.checkbox.current.classList.remove('error')
|
||||
this.props.item.updateState(checked, () => {
|
||||
this.checkbox.current.classList.add('ok')
|
||||
setTimeout(() => this.checkbox.current.classList.remove('ok'), 500)
|
||||
}, () => {
|
||||
this.checkbox.current.classList.add('error')
|
||||
})
|
||||
}//}}}
|
||||
editLabel() {//{{{
|
||||
let label = prompt('Edit label', this.props.item.Label)
|
||||
if (label === null)
|
||||
return
|
||||
|
||||
label = label.trim()
|
||||
if (label == '') {
|
||||
alert(`A label can't be empty.`)
|
||||
return
|
||||
}
|
||||
|
||||
this.label.current.classList.remove('error')
|
||||
this.props.item.updateLabel(label, () => {
|
||||
this.props.item.Label = label
|
||||
this.label.current.innerHTML = label
|
||||
this.label.current.classList.add('ok')
|
||||
setTimeout(() => this.label.current.classList.remove('ok'), 500)
|
||||
}, () => {
|
||||
this.label.current.classList.add('error')
|
||||
})
|
||||
|
||||
}//}}}
|
||||
delete() {//{{{
|
||||
if (this.props.ui.state.confirmDeletion) {
|
||||
if (!confirm(`Delete '${this.props.item.Label}'?`))
|
||||
return
|
||||
}
|
||||
|
||||
this.props.item.delete(() => {
|
||||
this.props.group.forceUpdate()
|
||||
}, err => {
|
||||
console.log(err)
|
||||
console.log('error')
|
||||
})
|
||||
}//}}}
|
||||
|
||||
setDragTarget(state) {//{{{
|
||||
this.setState({ dragTarget: state })
|
||||
}//}}}
|
||||
dragStart(evt) {//{{{
|
||||
// Shouldn't be needed, but in case the previous drag was bungled up, we reset.
|
||||
this.props.ui.dragReset()
|
||||
this.props.ui.dragItemSource = this
|
||||
|
||||
const img = new Image();
|
||||
evt.dataTransfer.setDragImage(img, 10, 10);
|
||||
}//}}}
|
||||
dragEnter(evt) {//{{{
|
||||
evt.preventDefault()
|
||||
this.props.ui.dragTarget(this)
|
||||
}//}}}
|
||||
dragEnd() {//{{{
|
||||
let groups = this.props.ui.props.groups
|
||||
let from = this.props.ui.dragItemSource.props.item
|
||||
let to = this.props.ui.dragItemTarget.props.item
|
||||
|
||||
this.props.ui.dragReset()
|
||||
|
||||
if (from.ID == to.ID)
|
||||
return
|
||||
|
||||
let fromGroup = groups.find(g => g.ID == from.GroupID)
|
||||
let toGroup = groups.find(g => g.ID == to.GroupID)
|
||||
|
||||
|
||||
from.Order = to.Order
|
||||
from.GroupID = toGroup.ID
|
||||
toGroup.items.forEach(i => {
|
||||
if (i.ID == from.ID)
|
||||
return
|
||||
if (i.Order <= to.Order)
|
||||
i.Order--
|
||||
})
|
||||
|
||||
if (fromGroup.ID != toGroup.ID) {
|
||||
fromGroup.items = fromGroup.items.filter(i => i.ID != from.ID)
|
||||
toGroup.items.push(from)
|
||||
}
|
||||
|
||||
this.props.ui.groupElements[fromGroup.ID].current.forceUpdate()
|
||||
this.props.ui.groupElements[toGroup.ID].current.forceUpdate()
|
||||
|
||||
from.move(to, () => {})
|
||||
}//}}}
|
||||
}
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
function refreshCSS() {
|
||||
let links = document.getElementsByTagName('link')
|
||||
Array.from(links).forEach(l=>{
|
||||
if (l.rel == 'stylesheet' && !l.hasAttribute('x-no-reload')) {
|
||||
let cache = Math.floor(Math.random()*100000)
|
||||
l.href = l.href.replace(/\?.*/, '') + `?cache=${cache}`
|
||||
console.log(l.href)
|
||||
}
|
||||
})
|
||||
}
|
||||
6
static/js/lib/fullcalendar.min.js
vendored
Normal file
1
static/js/lib/node_modules/.bin/marked
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../marked/bin/marked.js
|
||||
18
static/js/lib/node_modules/.package-lock.json
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "lib",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/marked": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-11.1.1.tgz",
|
||||
"integrity": "sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
static/js/lib/node_modules/marked/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# License information
|
||||
|
||||
## Contribution License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your code
|
||||
to be distributed under the MIT license. You are also implicitly verifying that
|
||||
all code is your original work. `</legalese>`
|
||||
|
||||
## Marked
|
||||
|
||||
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
||||
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
## Markdown
|
||||
|
||||
Copyright © 2004, John Gruber
|
||||
http://daringfireball.net/
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
||||
107
static/js/lib/node_modules/marked/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<a href="https://marked.js.org">
|
||||
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
||||
</a>
|
||||
|
||||
# Marked
|
||||
|
||||
[](https://www.npmjs.com/package/marked)
|
||||
[](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
|
||||
[](https://packagephobia.now.sh/result?p=marked)
|
||||
[](https://www.npmjs.com/package/marked)
|
||||
[](https://github.com/markedjs/marked/actions)
|
||||
[](https://snyk.io/test/npm/marked)
|
||||
|
||||
- ⚡ built for speed
|
||||
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
|
||||
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
|
||||
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
|
||||
|
||||
## Demo
|
||||
|
||||
Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
|
||||
|
||||
## Docs
|
||||
|
||||
Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
|
||||
|
||||
Also read about:
|
||||
|
||||
* [Options](https://marked.js.org/using_advanced)
|
||||
* [Extensibility](https://marked.js.org/using_pro)
|
||||
|
||||
## Compatibility
|
||||
|
||||
**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.
|
||||
|
||||
**Browser:** Not IE11 :)
|
||||
|
||||
## Installation
|
||||
|
||||
**CLI:**
|
||||
|
||||
```sh
|
||||
npm install -g marked
|
||||
```
|
||||
|
||||
**In-browser:**
|
||||
|
||||
```sh
|
||||
npm install marked
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/using_advanced#options) the output HTML. Please use a sanitize library, like [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [sanitize-html](https://github.com/apostrophecms/sanitize-html) or [insane](https://github.com/bevacqua/insane) on the *output* HTML! 🚨
|
||||
|
||||
```
|
||||
DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));
|
||||
```
|
||||
|
||||
**CLI**
|
||||
|
||||
``` bash
|
||||
# Example with stdin input
|
||||
$ marked -o hello.html
|
||||
hello world
|
||||
^D
|
||||
$ cat hello.html
|
||||
<p>hello world</p>
|
||||
```
|
||||
|
||||
```bash
|
||||
# Print all options
|
||||
$ marked --help
|
||||
```
|
||||
|
||||
**Browser**
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Marked in the browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>
|
||||
document.getElementById('content').innerHTML =
|
||||
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
or import esm module
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
|
||||
document.getElementById('content').innerHTML =
|
||||
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
|
||||
</script>
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)
|
||||
279
static/js/lib/node_modules/marked/bin/main.js
generated
vendored
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Marked CLI
|
||||
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
||||
*/
|
||||
|
||||
import { promises } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import { createRequire } from 'node:module';
|
||||
import { marked } from '../lib/marked.esm.js';
|
||||
|
||||
const { access, readFile, writeFile } = promises;
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
/**
|
||||
* @param {Process} nodeProcess inject process so it can be mocked in tests.
|
||||
*/
|
||||
export async function main(nodeProcess) {
|
||||
/**
|
||||
* Man Page
|
||||
*/
|
||||
async function help() {
|
||||
const { spawn } = await import('child_process');
|
||||
const { fileURLToPath } = await import('url');
|
||||
|
||||
const options = {
|
||||
cwd: nodeProcess.cwd(),
|
||||
env: nodeProcess.env,
|
||||
stdio: 'inherit'
|
||||
};
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const helpText = await readFile(resolve(__dirname, '../man/marked.1.md'), 'utf8');
|
||||
|
||||
// eslint-disable-next-line promise/param-names
|
||||
await new Promise(res => {
|
||||
spawn('man', [resolve(__dirname, '../man/marked.1')], options)
|
||||
.on('error', () => {
|
||||
console.log(helpText);
|
||||
})
|
||||
.on('close', res);
|
||||
});
|
||||
}
|
||||
|
||||
async function version() {
|
||||
const pkg = require('../package.json');
|
||||
console.log(pkg.version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main
|
||||
*/
|
||||
async function start(argv) {
|
||||
const files = [];
|
||||
const options = {};
|
||||
let input;
|
||||
let output;
|
||||
let string;
|
||||
let arg;
|
||||
let tokens;
|
||||
let config;
|
||||
let opt;
|
||||
let noclobber;
|
||||
|
||||
function getArg() {
|
||||
let arg = argv.shift();
|
||||
|
||||
if (arg.indexOf('--') === 0) {
|
||||
// e.g. --opt
|
||||
arg = arg.split('=');
|
||||
if (arg.length > 1) {
|
||||
// e.g. --opt=val
|
||||
argv.unshift(arg.slice(1).join('='));
|
||||
}
|
||||
arg = arg[0];
|
||||
} else if (arg[0] === '-') {
|
||||
if (arg.length > 2) {
|
||||
// e.g. -abc
|
||||
argv = arg.substring(1).split('').map(function(ch) {
|
||||
return '-' + ch;
|
||||
}).concat(argv);
|
||||
arg = argv.shift();
|
||||
} else {
|
||||
// e.g. -a
|
||||
}
|
||||
} else {
|
||||
// e.g. foo
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
while (argv.length) {
|
||||
arg = getArg();
|
||||
switch (arg) {
|
||||
case '-o':
|
||||
case '--output':
|
||||
output = argv.shift();
|
||||
break;
|
||||
case '-i':
|
||||
case '--input':
|
||||
input = argv.shift();
|
||||
break;
|
||||
case '-s':
|
||||
case '--string':
|
||||
string = argv.shift();
|
||||
break;
|
||||
case '-t':
|
||||
case '--tokens':
|
||||
tokens = true;
|
||||
break;
|
||||
case '-c':
|
||||
case '--config':
|
||||
config = argv.shift();
|
||||
break;
|
||||
case '-n':
|
||||
case '--no-clobber':
|
||||
noclobber = true;
|
||||
break;
|
||||
case '-h':
|
||||
case '--help':
|
||||
return await help();
|
||||
case '-v':
|
||||
case '--version':
|
||||
return await version();
|
||||
default:
|
||||
if (arg.indexOf('--') === 0) {
|
||||
opt = camelize(arg.replace(/^--(no-)?/, ''));
|
||||
if (!marked.defaults.hasOwnProperty(opt)) {
|
||||
continue;
|
||||
}
|
||||
if (arg.indexOf('--no-') === 0) {
|
||||
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
||||
? null
|
||||
: false;
|
||||
} else {
|
||||
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
||||
? argv.shift()
|
||||
: true;
|
||||
}
|
||||
} else {
|
||||
files.push(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function getData() {
|
||||
if (!input) {
|
||||
if (files.length <= 2) {
|
||||
if (string) {
|
||||
return string;
|
||||
}
|
||||
return await getStdin();
|
||||
}
|
||||
input = files.pop();
|
||||
}
|
||||
return await readFile(input, 'utf8');
|
||||
}
|
||||
|
||||
function resolveFile(file) {
|
||||
return resolve(file.replace(/^~/, homedir));
|
||||
}
|
||||
|
||||
function fileExists(file) {
|
||||
return access(resolveFile(file)).then(() => true, () => false);
|
||||
}
|
||||
|
||||
async function runConfig(file) {
|
||||
const configFile = resolveFile(file);
|
||||
let markedConfig;
|
||||
try {
|
||||
// try require for json
|
||||
markedConfig = require(configFile);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ERR_REQUIRE_ESM') {
|
||||
throw err;
|
||||
}
|
||||
// must import esm
|
||||
markedConfig = await import('file:///' + configFile);
|
||||
}
|
||||
|
||||
if (markedConfig.default) {
|
||||
markedConfig = markedConfig.default;
|
||||
}
|
||||
|
||||
if (typeof markedConfig === 'function') {
|
||||
markedConfig(marked);
|
||||
} else {
|
||||
marked.use(markedConfig);
|
||||
}
|
||||
}
|
||||
|
||||
const data = await getData();
|
||||
|
||||
if (config) {
|
||||
if (!await fileExists(config)) {
|
||||
throw Error(`Cannot load config file '${config}'`);
|
||||
}
|
||||
|
||||
await runConfig(config);
|
||||
} else {
|
||||
const defaultConfig = [
|
||||
'~/.marked.json',
|
||||
'~/.marked.js',
|
||||
'~/.marked/index.js'
|
||||
];
|
||||
|
||||
for (const configFile of defaultConfig) {
|
||||
if (await fileExists(configFile)) {
|
||||
await runConfig(configFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const html = tokens
|
||||
? JSON.stringify(marked.lexer(data, options), null, 2)
|
||||
: await marked.parse(data, options);
|
||||
|
||||
if (output) {
|
||||
if (noclobber && await fileExists(output)) {
|
||||
nodeProcess.stderr.write('marked: output file \'' + output + '\' already exists, disable the \'-n\' / \'--no-clobber\' flag to overwrite\n');
|
||||
nodeProcess.exit(1);
|
||||
}
|
||||
return await writeFile(output, html);
|
||||
}
|
||||
|
||||
nodeProcess.stdout.write(html + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
function getStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const stdin = nodeProcess.stdin;
|
||||
let buff = '';
|
||||
|
||||
stdin.setEncoding('utf8');
|
||||
|
||||
stdin.on('data', function(data) {
|
||||
buff += data;
|
||||
});
|
||||
|
||||
stdin.on('error', function(err) {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
stdin.on('end', function() {
|
||||
resolve(buff);
|
||||
});
|
||||
|
||||
stdin.resume();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
function camelize(text) {
|
||||
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
|
||||
return a + b.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await start(nodeProcess.argv.slice());
|
||||
nodeProcess.exit(0);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
nodeProcess.stderr.write('marked: output to ' + err.path + ': No such directory');
|
||||
}
|
||||
nodeProcess.stderr.write(err);
|
||||
return nodeProcess.exit(1);
|
||||
}
|
||||
}
|
||||
15
static/js/lib/node_modules/marked/bin/marked.js
generated
vendored
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Marked CLI
|
||||
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
||||
*/
|
||||
|
||||
import { main } from './main.js';
|
||||
|
||||
/**
|
||||
* Expose / Entry Point
|
||||
*/
|
||||
|
||||
process.title = 'marked';
|
||||
main(process);
|
||||
2442
static/js/lib/node_modules/marked/lib/marked.cjs
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.cjs.map
generated
vendored
Normal file
638
static/js/lib/node_modules/marked/lib/marked.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,638 @@
|
|||
// Generated by dts-bundle-generator v9.0.0
|
||||
|
||||
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
|
||||
export declare namespace Tokens {
|
||||
interface Space {
|
||||
type: "space";
|
||||
raw: string;
|
||||
}
|
||||
interface Code {
|
||||
type: "code";
|
||||
raw: string;
|
||||
codeBlockStyle?: "indented" | undefined;
|
||||
lang?: string | undefined;
|
||||
text: string;
|
||||
escaped?: boolean;
|
||||
}
|
||||
interface Heading {
|
||||
type: "heading";
|
||||
raw: string;
|
||||
depth: number;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Table {
|
||||
type: "table";
|
||||
raw: string;
|
||||
align: Array<"center" | "left" | "right" | null>;
|
||||
header: TableCell[];
|
||||
rows: TableCell[][];
|
||||
}
|
||||
interface TableCell {
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Hr {
|
||||
type: "hr";
|
||||
raw: string;
|
||||
}
|
||||
interface Blockquote {
|
||||
type: "blockquote";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface List {
|
||||
type: "list";
|
||||
raw: string;
|
||||
ordered: boolean;
|
||||
start: number | "";
|
||||
loose: boolean;
|
||||
items: ListItem[];
|
||||
}
|
||||
interface ListItem {
|
||||
type: "list_item";
|
||||
raw: string;
|
||||
task: boolean;
|
||||
checked?: boolean | undefined;
|
||||
loose: boolean;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Paragraph {
|
||||
type: "paragraph";
|
||||
raw: string;
|
||||
pre?: boolean | undefined;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface HTML {
|
||||
type: "html";
|
||||
raw: string;
|
||||
pre: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Text {
|
||||
type: "text";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens?: Token[];
|
||||
}
|
||||
interface Def {
|
||||
type: "def";
|
||||
raw: string;
|
||||
tag: string;
|
||||
href: string;
|
||||
title: string;
|
||||
}
|
||||
interface Escape {
|
||||
type: "escape";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Tag {
|
||||
type: "text" | "html";
|
||||
raw: string;
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Link {
|
||||
type: "link";
|
||||
raw: string;
|
||||
href: string;
|
||||
title?: string | null;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Image {
|
||||
type: "image";
|
||||
raw: string;
|
||||
href: string;
|
||||
title: string | null;
|
||||
text: string;
|
||||
}
|
||||
interface Strong {
|
||||
type: "strong";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Em {
|
||||
type: "em";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Codespan {
|
||||
type: "codespan";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Br {
|
||||
type: "br";
|
||||
raw: string;
|
||||
}
|
||||
interface Del {
|
||||
type: "del";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Generic {
|
||||
[index: string]: any;
|
||||
type: string;
|
||||
raw: string;
|
||||
tokens?: Token[] | undefined;
|
||||
}
|
||||
}
|
||||
export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, "href" | "title">>;
|
||||
export type TokensList = Token[] & {
|
||||
links: Links;
|
||||
};
|
||||
declare class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ""): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: "center" | "left" | "right" | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
declare class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
declare class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
declare const blockNormal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
export type BlockKeys = keyof typeof blockNormal;
|
||||
declare const inlineNormal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
export type InlineKeys = keyof typeof inlineNormal;
|
||||
/**
|
||||
* exports
|
||||
*/
|
||||
export declare const block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
export declare const inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
export interface Rules {
|
||||
block: Record<BlockKeys, RegExp>;
|
||||
inline: Record<InlineKeys, RegExp>;
|
||||
}
|
||||
declare class _Tokenizer {
|
||||
options: MarkedOptions;
|
||||
rules: Rules;
|
||||
lexer: _Lexer;
|
||||
constructor(options?: MarkedOptions);
|
||||
space(src: string): Tokens.Space | undefined;
|
||||
code(src: string): Tokens.Code | undefined;
|
||||
fences(src: string): Tokens.Code | undefined;
|
||||
heading(src: string): Tokens.Heading | undefined;
|
||||
hr(src: string): Tokens.Hr | undefined;
|
||||
blockquote(src: string): Tokens.Blockquote | undefined;
|
||||
list(src: string): Tokens.List | undefined;
|
||||
html(src: string): Tokens.HTML | undefined;
|
||||
def(src: string): Tokens.Def | undefined;
|
||||
table(src: string): Tokens.Table | undefined;
|
||||
lheading(src: string): Tokens.Heading | undefined;
|
||||
paragraph(src: string): Tokens.Paragraph | undefined;
|
||||
text(src: string): Tokens.Text | undefined;
|
||||
escape(src: string): Tokens.Escape | undefined;
|
||||
tag(src: string): Tokens.Tag | undefined;
|
||||
link(src: string): Tokens.Link | Tokens.Image | undefined;
|
||||
reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
|
||||
emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
|
||||
codespan(src: string): Tokens.Codespan | undefined;
|
||||
br(src: string): Tokens.Br | undefined;
|
||||
del(src: string): Tokens.Del | undefined;
|
||||
autolink(src: string): Tokens.Link | undefined;
|
||||
url(src: string): Tokens.Link | undefined;
|
||||
inlineText(src: string): Tokens.Text | undefined;
|
||||
}
|
||||
declare class _Hooks {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
static passThroughHooks: Set<string>;
|
||||
/**
|
||||
* Process markdown before marked
|
||||
*/
|
||||
preprocess(markdown: string): string;
|
||||
/**
|
||||
* Process HTML after marked is finished
|
||||
*/
|
||||
postprocess(html: string): string;
|
||||
/**
|
||||
* Process all tokens before walk tokens
|
||||
*/
|
||||
processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
|
||||
}
|
||||
export interface TokenizerThis {
|
||||
lexer: _Lexer;
|
||||
}
|
||||
export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
|
||||
export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
|
||||
export interface TokenizerExtension {
|
||||
name: string;
|
||||
level: "block" | "inline";
|
||||
start?: TokenizerStartFunction | undefined;
|
||||
tokenizer: TokenizerExtensionFunction;
|
||||
childTokens?: string[] | undefined;
|
||||
}
|
||||
export interface RendererThis {
|
||||
parser: _Parser;
|
||||
}
|
||||
export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
|
||||
export interface RendererExtension {
|
||||
name: string;
|
||||
renderer: RendererExtensionFunction;
|
||||
}
|
||||
export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
export type HooksApi = Omit<_Hooks, "constructor" | "options">;
|
||||
export type HooksObject = {
|
||||
[K in keyof HooksApi]?: (...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
|
||||
};
|
||||
export type RendererApi = Omit<_Renderer, "constructor" | "options">;
|
||||
export type RendererObject = {
|
||||
[K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
|
||||
};
|
||||
export type TokenizerApi = Omit<_Tokenizer, "constructor" | "options" | "rules" | "lexer">;
|
||||
export type TokenizerObject = {
|
||||
[K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
|
||||
};
|
||||
export interface MarkedExtension {
|
||||
/**
|
||||
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
||||
*/
|
||||
async?: boolean;
|
||||
/**
|
||||
* Enable GFM line breaks. This option requires the gfm option to be true.
|
||||
*/
|
||||
breaks?: boolean | undefined;
|
||||
/**
|
||||
* Add tokenizers and renderers to marked
|
||||
*/
|
||||
extensions?: TokenizerAndRendererExtension[] | undefined | null;
|
||||
/**
|
||||
* Enable GitHub flavored markdown.
|
||||
*/
|
||||
gfm?: boolean | undefined;
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
* preprocess is called to process markdown before sending it to marked.
|
||||
* processAllTokens is called with the TokensList before walkTokens.
|
||||
* postprocess is called to process html after marked has finished parsing.
|
||||
*/
|
||||
hooks?: HooksObject | undefined | null;
|
||||
/**
|
||||
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
||||
*/
|
||||
pedantic?: boolean | undefined;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: RendererObject | undefined | null;
|
||||
/**
|
||||
* Shows an HTML error message when rendering fails.
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: TokenizerObject | undefined | null;
|
||||
/**
|
||||
* The walkTokens function gets called with every token.
|
||||
* Child tokens are called before moving on to sibling tokens.
|
||||
* Each token is passed by reference so updates are persisted when passed to the parser.
|
||||
* The return value of the function is ignored.
|
||||
*/
|
||||
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
||||
}
|
||||
export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
*/
|
||||
hooks?: _Hooks | undefined | null;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: _Renderer | undefined | null;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: _Tokenizer | undefined | null;
|
||||
/**
|
||||
* Custom extensions
|
||||
*/
|
||||
extensions?: null | {
|
||||
renderers: {
|
||||
[name: string]: RendererExtensionFunction;
|
||||
};
|
||||
childTokens: {
|
||||
[name: string]: string[];
|
||||
};
|
||||
inline?: TokenizerExtensionFunction[];
|
||||
block?: TokenizerExtensionFunction[];
|
||||
startInline?: TokenizerStartFunction[];
|
||||
startBlock?: TokenizerStartFunction[];
|
||||
};
|
||||
/**
|
||||
* walkTokens function returns array of values for Promise.all
|
||||
*/
|
||||
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
||||
}
|
||||
declare class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): {
|
||||
block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
declare function _getDefaults(): MarkedOptions;
|
||||
declare let _defaults: MarkedOptions;
|
||||
export type MaybePromise = void | Promise<void>;
|
||||
export declare class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: MarkedOptions) => this;
|
||||
parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
Parser: typeof _Parser;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: MarkedOptions): this;
|
||||
lexer(src: string, options?: MarkedOptions): TokensList;
|
||||
parser(tokens: Token[], options?: MarkedOptions): string;
|
||||
}
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
export declare function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML. Wil be a Promise of string if async is set to true by any extensions.
|
||||
*/
|
||||
export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
|
||||
export declare namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
export declare const options: (options: MarkedOptions) => typeof marked;
|
||||
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
export declare const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
export declare const parse: typeof marked;
|
||||
export declare const parser: typeof _Parser.parse;
|
||||
export declare const lexer: typeof _Lexer.lex;
|
||||
|
||||
export {
|
||||
_Hooks as Hooks,
|
||||
_Lexer as Lexer,
|
||||
_Parser as Parser,
|
||||
_Renderer as Renderer,
|
||||
_TextRenderer as TextRenderer,
|
||||
_Tokenizer as Tokenizer,
|
||||
_defaults as defaults,
|
||||
_getDefaults as getDefaults,
|
||||
};
|
||||
|
||||
export {};
|
||||
638
static/js/lib/node_modules/marked/lib/marked.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,638 @@
|
|||
// Generated by dts-bundle-generator v9.0.0
|
||||
|
||||
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
|
||||
export declare namespace Tokens {
|
||||
interface Space {
|
||||
type: "space";
|
||||
raw: string;
|
||||
}
|
||||
interface Code {
|
||||
type: "code";
|
||||
raw: string;
|
||||
codeBlockStyle?: "indented" | undefined;
|
||||
lang?: string | undefined;
|
||||
text: string;
|
||||
escaped?: boolean;
|
||||
}
|
||||
interface Heading {
|
||||
type: "heading";
|
||||
raw: string;
|
||||
depth: number;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Table {
|
||||
type: "table";
|
||||
raw: string;
|
||||
align: Array<"center" | "left" | "right" | null>;
|
||||
header: TableCell[];
|
||||
rows: TableCell[][];
|
||||
}
|
||||
interface TableCell {
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Hr {
|
||||
type: "hr";
|
||||
raw: string;
|
||||
}
|
||||
interface Blockquote {
|
||||
type: "blockquote";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface List {
|
||||
type: "list";
|
||||
raw: string;
|
||||
ordered: boolean;
|
||||
start: number | "";
|
||||
loose: boolean;
|
||||
items: ListItem[];
|
||||
}
|
||||
interface ListItem {
|
||||
type: "list_item";
|
||||
raw: string;
|
||||
task: boolean;
|
||||
checked?: boolean | undefined;
|
||||
loose: boolean;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Paragraph {
|
||||
type: "paragraph";
|
||||
raw: string;
|
||||
pre?: boolean | undefined;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface HTML {
|
||||
type: "html";
|
||||
raw: string;
|
||||
pre: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Text {
|
||||
type: "text";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens?: Token[];
|
||||
}
|
||||
interface Def {
|
||||
type: "def";
|
||||
raw: string;
|
||||
tag: string;
|
||||
href: string;
|
||||
title: string;
|
||||
}
|
||||
interface Escape {
|
||||
type: "escape";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Tag {
|
||||
type: "text" | "html";
|
||||
raw: string;
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Link {
|
||||
type: "link";
|
||||
raw: string;
|
||||
href: string;
|
||||
title?: string | null;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Image {
|
||||
type: "image";
|
||||
raw: string;
|
||||
href: string;
|
||||
title: string | null;
|
||||
text: string;
|
||||
}
|
||||
interface Strong {
|
||||
type: "strong";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Em {
|
||||
type: "em";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Codespan {
|
||||
type: "codespan";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Br {
|
||||
type: "br";
|
||||
raw: string;
|
||||
}
|
||||
interface Del {
|
||||
type: "del";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Generic {
|
||||
[index: string]: any;
|
||||
type: string;
|
||||
raw: string;
|
||||
tokens?: Token[] | undefined;
|
||||
}
|
||||
}
|
||||
export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, "href" | "title">>;
|
||||
export type TokensList = Token[] & {
|
||||
links: Links;
|
||||
};
|
||||
declare class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ""): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: "center" | "left" | "right" | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
declare class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
declare class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
declare const blockNormal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
export type BlockKeys = keyof typeof blockNormal;
|
||||
declare const inlineNormal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
export type InlineKeys = keyof typeof inlineNormal;
|
||||
/**
|
||||
* exports
|
||||
*/
|
||||
export declare const block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
export declare const inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
export interface Rules {
|
||||
block: Record<BlockKeys, RegExp>;
|
||||
inline: Record<InlineKeys, RegExp>;
|
||||
}
|
||||
declare class _Tokenizer {
|
||||
options: MarkedOptions;
|
||||
rules: Rules;
|
||||
lexer: _Lexer;
|
||||
constructor(options?: MarkedOptions);
|
||||
space(src: string): Tokens.Space | undefined;
|
||||
code(src: string): Tokens.Code | undefined;
|
||||
fences(src: string): Tokens.Code | undefined;
|
||||
heading(src: string): Tokens.Heading | undefined;
|
||||
hr(src: string): Tokens.Hr | undefined;
|
||||
blockquote(src: string): Tokens.Blockquote | undefined;
|
||||
list(src: string): Tokens.List | undefined;
|
||||
html(src: string): Tokens.HTML | undefined;
|
||||
def(src: string): Tokens.Def | undefined;
|
||||
table(src: string): Tokens.Table | undefined;
|
||||
lheading(src: string): Tokens.Heading | undefined;
|
||||
paragraph(src: string): Tokens.Paragraph | undefined;
|
||||
text(src: string): Tokens.Text | undefined;
|
||||
escape(src: string): Tokens.Escape | undefined;
|
||||
tag(src: string): Tokens.Tag | undefined;
|
||||
link(src: string): Tokens.Link | Tokens.Image | undefined;
|
||||
reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
|
||||
emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
|
||||
codespan(src: string): Tokens.Codespan | undefined;
|
||||
br(src: string): Tokens.Br | undefined;
|
||||
del(src: string): Tokens.Del | undefined;
|
||||
autolink(src: string): Tokens.Link | undefined;
|
||||
url(src: string): Tokens.Link | undefined;
|
||||
inlineText(src: string): Tokens.Text | undefined;
|
||||
}
|
||||
declare class _Hooks {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
static passThroughHooks: Set<string>;
|
||||
/**
|
||||
* Process markdown before marked
|
||||
*/
|
||||
preprocess(markdown: string): string;
|
||||
/**
|
||||
* Process HTML after marked is finished
|
||||
*/
|
||||
postprocess(html: string): string;
|
||||
/**
|
||||
* Process all tokens before walk tokens
|
||||
*/
|
||||
processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
|
||||
}
|
||||
export interface TokenizerThis {
|
||||
lexer: _Lexer;
|
||||
}
|
||||
export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
|
||||
export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
|
||||
export interface TokenizerExtension {
|
||||
name: string;
|
||||
level: "block" | "inline";
|
||||
start?: TokenizerStartFunction | undefined;
|
||||
tokenizer: TokenizerExtensionFunction;
|
||||
childTokens?: string[] | undefined;
|
||||
}
|
||||
export interface RendererThis {
|
||||
parser: _Parser;
|
||||
}
|
||||
export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
|
||||
export interface RendererExtension {
|
||||
name: string;
|
||||
renderer: RendererExtensionFunction;
|
||||
}
|
||||
export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
export type HooksApi = Omit<_Hooks, "constructor" | "options">;
|
||||
export type HooksObject = {
|
||||
[K in keyof HooksApi]?: (...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
|
||||
};
|
||||
export type RendererApi = Omit<_Renderer, "constructor" | "options">;
|
||||
export type RendererObject = {
|
||||
[K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
|
||||
};
|
||||
export type TokenizerApi = Omit<_Tokenizer, "constructor" | "options" | "rules" | "lexer">;
|
||||
export type TokenizerObject = {
|
||||
[K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
|
||||
};
|
||||
export interface MarkedExtension {
|
||||
/**
|
||||
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
||||
*/
|
||||
async?: boolean;
|
||||
/**
|
||||
* Enable GFM line breaks. This option requires the gfm option to be true.
|
||||
*/
|
||||
breaks?: boolean | undefined;
|
||||
/**
|
||||
* Add tokenizers and renderers to marked
|
||||
*/
|
||||
extensions?: TokenizerAndRendererExtension[] | undefined | null;
|
||||
/**
|
||||
* Enable GitHub flavored markdown.
|
||||
*/
|
||||
gfm?: boolean | undefined;
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
* preprocess is called to process markdown before sending it to marked.
|
||||
* processAllTokens is called with the TokensList before walkTokens.
|
||||
* postprocess is called to process html after marked has finished parsing.
|
||||
*/
|
||||
hooks?: HooksObject | undefined | null;
|
||||
/**
|
||||
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
||||
*/
|
||||
pedantic?: boolean | undefined;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: RendererObject | undefined | null;
|
||||
/**
|
||||
* Shows an HTML error message when rendering fails.
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: TokenizerObject | undefined | null;
|
||||
/**
|
||||
* The walkTokens function gets called with every token.
|
||||
* Child tokens are called before moving on to sibling tokens.
|
||||
* Each token is passed by reference so updates are persisted when passed to the parser.
|
||||
* The return value of the function is ignored.
|
||||
*/
|
||||
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
||||
}
|
||||
export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
*/
|
||||
hooks?: _Hooks | undefined | null;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: _Renderer | undefined | null;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: _Tokenizer | undefined | null;
|
||||
/**
|
||||
* Custom extensions
|
||||
*/
|
||||
extensions?: null | {
|
||||
renderers: {
|
||||
[name: string]: RendererExtensionFunction;
|
||||
};
|
||||
childTokens: {
|
||||
[name: string]: string[];
|
||||
};
|
||||
inline?: TokenizerExtensionFunction[];
|
||||
block?: TokenizerExtensionFunction[];
|
||||
startInline?: TokenizerStartFunction[];
|
||||
startBlock?: TokenizerStartFunction[];
|
||||
};
|
||||
/**
|
||||
* walkTokens function returns array of values for Promise.all
|
||||
*/
|
||||
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
||||
}
|
||||
declare class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): {
|
||||
block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
declare function _getDefaults(): MarkedOptions;
|
||||
declare let _defaults: MarkedOptions;
|
||||
export type MaybePromise = void | Promise<void>;
|
||||
export declare class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: MarkedOptions) => this;
|
||||
parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
Parser: typeof _Parser;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: MarkedOptions): this;
|
||||
lexer(src: string, options?: MarkedOptions): TokensList;
|
||||
parser(tokens: Token[], options?: MarkedOptions): string;
|
||||
}
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
export declare function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML. Wil be a Promise of string if async is set to true by any extensions.
|
||||
*/
|
||||
export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
|
||||
export declare namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
export declare const options: (options: MarkedOptions) => typeof marked;
|
||||
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
export declare const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
export declare const parse: typeof marked;
|
||||
export declare const parser: typeof _Parser.parse;
|
||||
export declare const lexer: typeof _Lexer.lex;
|
||||
|
||||
export {
|
||||
_Hooks as Hooks,
|
||||
_Lexer as Lexer,
|
||||
_Parser as Parser,
|
||||
_Renderer as Renderer,
|
||||
_TextRenderer as TextRenderer,
|
||||
_Tokenizer as Tokenizer,
|
||||
_defaults as defaults,
|
||||
_getDefaults as getDefaults,
|
||||
};
|
||||
|
||||
export {};
|
||||
2424
static/js/lib/node_modules/marked/lib/marked.esm.js
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.esm.js.map
generated
vendored
Normal file
2448
static/js/lib/node_modules/marked/lib/marked.umd.js
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.umd.js.map
generated
vendored
Normal file
111
static/js/lib/node_modules/marked/man/marked.1
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
.TH "MARKED" "1" "December 2023" "11.1.0"
|
||||
.SH "NAME"
|
||||
\fBmarked\fR \- a javascript markdown parser
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
\fBmarked\fP [\fB\-o\fP <output file>] [\fB\-i\fP <input file>] [\fB\-s\fP <markdown string>] [\fB\-c\fP <config file>] [\fB\-\-help\fP] [\fB\-\-version\fP] [\fB\-\-tokens\fP] [\fB\-\-no\-clobber\fP] [\fB\-\-pedantic\fP] [\fB\-\-gfm\fP] [\fB\-\-breaks\fP] [\fB\-\-no\-etc\.\.\.\fP] [\fB\-\-silent\fP] [filename]
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
marked is a full\-featured javascript markdown parser, built for speed\.
|
||||
.br
|
||||
It also includes multiple GFM features\.
|
||||
.SH EXAMPLES
|
||||
.RS 2
|
||||
.nf
|
||||
cat in\.md | marked > out\.html
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
echo "hello *world*" | marked
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
marked \-o out\.html \-i in\.md \-\-gfm
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
marked \-\-output="hello world\.html" \-i in\.md \-\-no\-breaks
|
||||
.fi
|
||||
.RE
|
||||
.SH OPTIONS
|
||||
|
||||
.RS 1
|
||||
.IP \(bu 2
|
||||
\-o, \-\-output [output file]
|
||||
.br
|
||||
Specify file output\. If none is specified, write to stdout\.
|
||||
.IP \(bu 2
|
||||
\-i, \-\-input [input file]
|
||||
.br
|
||||
Specify file input, otherwise use last argument as input file\.
|
||||
.br
|
||||
If no input file is specified, read from stdin\.
|
||||
.IP \(bu 2
|
||||
\-s, \-\-string [markdown string]
|
||||
.br
|
||||
Specify string input instead of a file\.
|
||||
.IP \(bu 2
|
||||
\-c, \-\-config [config file]
|
||||
.br
|
||||
Specify config file to use instead of the default \fB~/\.marked\.json\fP or \fB~/\.marked\.js\fP or \fB~/\.marked/index\.js\fP\|\.
|
||||
.IP \(bu 2
|
||||
\-t, \-\-tokens
|
||||
.br
|
||||
Output a token list instead of html\.
|
||||
.IP \(bu 2
|
||||
\-n, \-\-no\-clobber
|
||||
.br
|
||||
Do not overwrite \fBoutput\fP if it exists\.
|
||||
.IP \(bu 2
|
||||
\-\-pedantic
|
||||
.br
|
||||
Conform to obscure parts of markdown\.pl as much as possible\.
|
||||
.br
|
||||
Don't fix original markdown bugs\.
|
||||
.IP \(bu 2
|
||||
\-\-gfm
|
||||
.br
|
||||
Enable github flavored markdown\.
|
||||
.IP \(bu 2
|
||||
\-\-breaks
|
||||
.br
|
||||
Enable GFM line breaks\. Only works with the gfm option\.
|
||||
.IP \(bu 2
|
||||
\-\-no\-breaks, \-no\-etc\.\.\.
|
||||
.br
|
||||
The inverse of any of the marked options above\.
|
||||
.IP \(bu 2
|
||||
\-\-silent
|
||||
.br
|
||||
Silence error output\.
|
||||
.IP \(bu 2
|
||||
\-h, \-\-help
|
||||
.br
|
||||
Display help information\.
|
||||
|
||||
.RE
|
||||
.SH CONFIGURATION
|
||||
.P
|
||||
For configuring and running programmatically\.
|
||||
.P
|
||||
Example
|
||||
.RS 2
|
||||
.nf
|
||||
import { Marked } from 'marked';
|
||||
const marked = new Marked({ gfm: true });
|
||||
marked\.parse('*foo*');
|
||||
.fi
|
||||
.RE
|
||||
.SH BUGS
|
||||
.P
|
||||
Please report any bugs to https://github.com/markedjs/marked
|
||||
.SH LICENSE
|
||||
.P
|
||||
Copyright (c) 2011\-2014, Christopher Jeffrey (MIT License)\.
|
||||
.SH SEE ALSO
|
||||
.P
|
||||
markdown(1), nodejs(1)
|
||||
|
||||
92
static/js/lib/node_modules/marked/man/marked.1.md
generated
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# marked(1) -- a javascript markdown parser
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`marked` [`-o` <output file>] [`-i` <input file>] [`-s` <markdown string>] [`-c` <config file>] [`--help`] [`--version`] [`--tokens`] [`--no-clobber`] [`--pedantic`] [`--gfm`] [`--breaks`] [`--no-etc...`] [`--silent`] [filename]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
marked is a full-featured javascript markdown parser, built for speed.
|
||||
It also includes multiple GFM features.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```sh
|
||||
cat in.md | marked > out.html
|
||||
```
|
||||
|
||||
```sh
|
||||
echo "hello *world*" | marked
|
||||
```
|
||||
|
||||
```sh
|
||||
marked -o out.html -i in.md --gfm
|
||||
```
|
||||
|
||||
```sh
|
||||
marked --output="hello world.html" -i in.md --no-breaks
|
||||
```
|
||||
|
||||
## OPTIONS
|
||||
|
||||
* -o, --output [output file]
|
||||
Specify file output. If none is specified, write to stdout.
|
||||
|
||||
* -i, --input [input file]
|
||||
Specify file input, otherwise use last argument as input file.
|
||||
If no input file is specified, read from stdin.
|
||||
|
||||
* -s, --string [markdown string]
|
||||
Specify string input instead of a file.
|
||||
|
||||
* -c, --config [config file]
|
||||
Specify config file to use instead of the default `~/.marked.json` or `~/.marked.js` or `~/.marked/index.js`.
|
||||
|
||||
* -t, --tokens
|
||||
Output a token list instead of html.
|
||||
|
||||
* -n, --no-clobber
|
||||
Do not overwrite `output` if it exists.
|
||||
|
||||
* --pedantic
|
||||
Conform to obscure parts of markdown.pl as much as possible.
|
||||
Don't fix original markdown bugs.
|
||||
|
||||
* --gfm
|
||||
Enable github flavored markdown.
|
||||
|
||||
* --breaks
|
||||
Enable GFM line breaks. Only works with the gfm option.
|
||||
|
||||
* --no-breaks, -no-etc...
|
||||
The inverse of any of the marked options above.
|
||||
|
||||
* --silent
|
||||
Silence error output.
|
||||
|
||||
* -h, --help
|
||||
Display help information.
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
For configuring and running programmatically.
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
import { Marked } from 'marked';
|
||||
const marked = new Marked({ gfm: true });
|
||||
marked.parse('*foo*');
|
||||
```
|
||||
|
||||
## BUGS
|
||||
|
||||
Please report any bugs to <https://github.com/markedjs/marked>.
|
||||
|
||||
## LICENSE
|
||||
|
||||
Copyright (c) 2011-2014, Christopher Jeffrey (MIT License).
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
markdown(1), nodejs(1)
|
||||
6
static/js/lib/node_modules/marked/marked.min.js
generated
vendored
Normal file
108
static/js/lib/node_modules/marked/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"name": "marked",
|
||||
"description": "A markdown parser built for speed",
|
||||
"author": "Christopher Jeffrey",
|
||||
"version": "11.1.1",
|
||||
"type": "module",
|
||||
"main": "./lib/marked.cjs",
|
||||
"module": "./lib/marked.esm.js",
|
||||
"browser": "./lib/marked.umd.js",
|
||||
"types": "./lib/marked.d.ts",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"man": "./man/marked.1",
|
||||
"files": [
|
||||
"bin/",
|
||||
"lib/",
|
||||
"man/",
|
||||
"marked.min.js"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./lib/marked.d.ts",
|
||||
"default": "./lib/marked.esm.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./lib/marked.d.cts",
|
||||
"default": "./lib/marked.cjs"
|
||||
}
|
||||
},
|
||||
"./bin/marked": "./bin/marked.js",
|
||||
"./marked.min.js": "./marked.min.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"repository": "git://github.com/markedjs/marked.git",
|
||||
"homepage": "https://marked.js.org",
|
||||
"bugs": {
|
||||
"url": "http://github.com/markedjs/marked/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"markup",
|
||||
"html"
|
||||
],
|
||||
"tags": [
|
||||
"markdown",
|
||||
"markup",
|
||||
"html"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@markedjs/testutils": "9.1.5-0",
|
||||
"@arethetypeswrong/cli": "^0.13.5",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"@semantic-release/commit-analyzer": "^11.1.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.2.6",
|
||||
"@semantic-release/npm": "^11.0.2",
|
||||
"@semantic-release/release-notes-generator": "^12.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
||||
"@typescript-eslint/parser": "^6.13.2",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"commonmark": "0.30.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dts-bundle-generator": "^9.0.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-standard": "^17.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-n": "^16.5.0",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"highlight.js": "^11.9.0",
|
||||
"markdown-it": "13.0.2",
|
||||
"marked-highlight": "^2.1.0",
|
||||
"marked-man": "^2.0.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"recheck": "^4.4.5",
|
||||
"rollup": "^4.9.1",
|
||||
"semantic-release": "^22.0.12",
|
||||
"titleize": "^4.0.0",
|
||||
"ts-expect": "^1.3.0",
|
||||
"typescript": "5.3.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run build && npm run test:specs && npm run test:unit",
|
||||
"test:all": "npm test && npm run test:umd && npm run test:types && npm run test:lint",
|
||||
"test:unit": "node --test --test-reporter=spec test/unit",
|
||||
"test:specs": "node --test --test-reporter=spec test/run-spec-tests.js",
|
||||
"test:lint": "eslint .",
|
||||
"test:redos": "node test/recheck.js > vuln.js",
|
||||
"test:types": "tsc --project tsconfig-type-test.json && attw -P --exclude-entrypoints ./bin/marked ./marked.min.js",
|
||||
"test:umd": "node test/umd-test.js",
|
||||
"test:update": "node test/update-specs.js",
|
||||
"rules": "node test/rules.js",
|
||||
"bench": "npm run build && node test/bench.js",
|
||||
"lint": "eslint --fix .",
|
||||
"build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js",
|
||||
"build": "npm run rollup && npm run build:types && npm run build:man",
|
||||
"build:docs": "npm run build && node docs/build.js",
|
||||
"build:types": "tsc && dts-bundle-generator --project tsconfig.json -o lib/marked.d.ts src/marked.ts && dts-bundle-generator --project tsconfig.json -o lib/marked.d.cts src/marked.ts",
|
||||
"build:man": "marked-man man/marked.1.md > man/marked.1",
|
||||
"rollup": "rollup -c rollup.config.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
||||
23
static/js/lib/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "lib",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"marked": "^11.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/marked": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-11.1.1.tgz",
|
||||
"integrity": "sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
static/js/lib/package.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"marked": "^11.1.1"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
export class Session {
|
||||
constructor(app) {
|
||||
constructor(app) {//{{{
|
||||
this.app = app
|
||||
this.UUID = ''
|
||||
this.initialized = false
|
||||
this.UserID = 0
|
||||
}
|
||||
}//}}}
|
||||
|
||||
initialize() {//{{{
|
||||
// Retrieving the stored session UUID, if any.
|
||||
// If one found, validate with server.
|
||||
|
||||
|
||||
// If the browser doesn't know anything about a session,
|
||||
// a call to /session/create is necessary to retrieve a session UUID.
|
||||
let uuid= window.localStorage.getItem("session.UUID")
|
||||
if(uuid === null) {
|
||||
let uuid = window.localStorage.getItem("session.UUID")
|
||||
if (uuid === null) {
|
||||
this.create()
|
||||
return
|
||||
}
|
||||
|
|
@ -25,47 +24,49 @@ export class Session {
|
|||
// A call to /session/retrieve with a session UUID validates that the
|
||||
// session is still valid and returns all session information.
|
||||
this.UUID = uuid
|
||||
this.app.request('/session/retrieve', {})
|
||||
.then(res=>{
|
||||
if(res.Valid) {
|
||||
// Session exists on server.
|
||||
// Not necessarily authenticated.
|
||||
this.UserID = res.Session.UserID // could be 0
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
} else {
|
||||
// Session has probably expired. A new is required.
|
||||
this.create()
|
||||
}
|
||||
})
|
||||
.catch(this.app.responseError)
|
||||
this.app.request('/_session/retrieve', {})
|
||||
.then(res => {
|
||||
if (res.Error === undefined) {
|
||||
// Session exists on server.
|
||||
// Not necessarily authenticated.
|
||||
this.UserID = res.Session.UserID // could be 0
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
}
|
||||
})
|
||||
.catch(this.app.responseError)
|
||||
}//}}}
|
||||
create() {//{{{
|
||||
this.app.request('/session/create', {})
|
||||
.then(res=>{
|
||||
this.UUID = res.Session.UUID
|
||||
window.localStorage.setItem('session.UUID', this.UUID)
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
})
|
||||
.catch(this.responseError)
|
||||
this.app.request('/_session/new', {})
|
||||
.then(res => {
|
||||
this.UUID = res.Session.UUID
|
||||
window.localStorage.setItem('session.UUID', this.UUID)
|
||||
this.initialized = true
|
||||
this.app.forceUpdate()
|
||||
})
|
||||
.catch(this.responseError)
|
||||
}//}}}
|
||||
reset() {//{{{
|
||||
window.localStorage.removeItem('session.UUID')
|
||||
this.initialized = false
|
||||
this.UserID = 0
|
||||
}//}}}
|
||||
authenticate(username, password) {//{{{
|
||||
this.app.login.current.authentication_failed.value = false
|
||||
|
||||
this.app.request('/session/authenticate', {
|
||||
this.app.request('/_session/authenticate', {
|
||||
username,
|
||||
password,
|
||||
})
|
||||
.then(res=>{
|
||||
if(res.Authenticated) {
|
||||
this.UserID = res.Session.UserID
|
||||
this.app.forceUpdate()
|
||||
} else {
|
||||
this.app.login.current.authentication_failed.value = true
|
||||
}
|
||||
})
|
||||
.catch(this.app.responseError)
|
||||
.then(res => {
|
||||
if (res.Authenticated) {
|
||||
this.UserID = res.UserID
|
||||
this.app.forceUpdate()
|
||||
} else {
|
||||
this.app.login.current.authentication_failed.value = true
|
||||
}
|
||||
})
|
||||
.catch(this.app.responseError)
|
||||
}//}}}
|
||||
authenticated() {//{{{
|
||||
return this.UserID != 0
|
||||
|
|
|
|||
|
|
@ -1,44 +1,61 @@
|
|||
@import "theme.less";
|
||||
|
||||
#login {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
height: 100%;
|
||||
background: #eee;
|
||||
|
||||
input {
|
||||
max-width: 300px;
|
||||
margin-bottom: 32px;
|
||||
.header {
|
||||
background: @theme_gradient;
|
||||
width: 100%;
|
||||
border: 0px;
|
||||
border-bottom: 1px solid #444;
|
||||
|
||||
font-size: 18pt;
|
||||
background-color: @background;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
max-width: 300px;
|
||||
border: 1px solid #666;
|
||||
background: @background;
|
||||
color: #444;
|
||||
padding: 16px 32px;
|
||||
font-size: 1em;
|
||||
align-self: center;
|
||||
|
||||
&:hover {
|
||||
background: #ddd;
|
||||
}
|
||||
}
|
||||
|
||||
.auth-failed {
|
||||
margin-top: 32px;
|
||||
color: #a00;
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
|
||||
h1 {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
.fields {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
padding: 32px;
|
||||
|
||||
input {
|
||||
margin-bottom: 32px;
|
||||
border: 0px;
|
||||
border: 1px solid #444;
|
||||
padding: 8px;
|
||||
width: 100%;
|
||||
|
||||
font-size: 1.25em;
|
||||
background-color: @background;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid #666;
|
||||
background: @background;
|
||||
color: #444;
|
||||
padding: 12px 24px;
|
||||
font-size: 1.25em;
|
||||
align-self: center;
|
||||
|
||||
&:hover {
|
||||
background: #ddd;
|
||||
}
|
||||
}
|
||||
|
||||
.auth-failed {
|
||||
margin-top: 32px;
|
||||
color: #a00;
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ do
|
|||
clear
|
||||
if make -j12; then
|
||||
echo -e "\n\e[32;1mOK!\e[0m"
|
||||
curl -s http://notes.lan:1371/css_updated
|
||||
curl -s http://notes.lan:1371/_ws/css_update
|
||||
sleep 1
|
||||
clear
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -8,10 +8,18 @@ html {
|
|||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
*,*:focus,*:hover{
|
||||
outline:none;
|
||||
}
|
||||
|
||||
[onClick] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
label {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
html, body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
|
|
@ -23,13 +31,18 @@ html, body {
|
|||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0px;
|
||||
font-size: 1.5em;
|
||||
font-size: 1.25em;
|
||||
color: @header_1;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 32px;
|
||||
font-size: 1.25em;
|
||||
font-size: 1.0em;
|
||||
color: @header_1;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.0em;
|
||||
}
|
||||
|
||||
button {
|
||||
|
|
@ -56,6 +69,14 @@ button {
|
|||
border: 2px solid #000;
|
||||
box-shadow: 5px 5px 8px 0px rgba(0,0,0,0.5);
|
||||
z-index: 1025;
|
||||
width: min-content;
|
||||
|
||||
.section {
|
||||
padding: 16px 16px 0px 16px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
color: @accent_3;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: 16px;
|
||||
|
|
@ -149,22 +170,22 @@ button {
|
|||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.checks {
|
||||
display: grid;
|
||||
grid-template-columns: min-content 1fr;
|
||||
grid-gap: 4px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
header {
|
||||
display: grid;
|
||||
grid-area: header;
|
||||
grid-template-columns: min-content 1fr repeat(3, min-content);
|
||||
grid-template-columns: min-content 1fr repeat(6, min-content);
|
||||
align-items: center;
|
||||
//background: @accent_1;
|
||||
padding: 8px 0px;
|
||||
color: darken(@accent_1, 35%);
|
||||
background: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
background: linear-gradient(to right, #f5af19, #f12711);
|
||||
background: linear-gradient(to right, #fdc830, #f37335);
|
||||
background: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
background: linear-gradient(to right, #659999, #f4791f);
|
||||
background: linear-gradient(to right, #3e5151, #decba4);
|
||||
background: @theme_gradient;
|
||||
color: #fff;
|
||||
|
||||
&.modified {
|
||||
|
|
@ -187,17 +208,7 @@ header {
|
|||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
.add {
|
||||
padding-right: 16px;
|
||||
cursor: pointer;
|
||||
|
||||
img {
|
||||
cursor: pointer;
|
||||
height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.keys {
|
||||
.markdown, .checklist, .search, .add, .keys {
|
||||
padding-right: 16px;
|
||||
|
||||
img {
|
||||
|
|
@ -220,6 +231,7 @@ header {
|
|||
padding: 16px;
|
||||
background-color: #333;
|
||||
color: #ddd;
|
||||
z-index: 100; // Over crumbs shadow
|
||||
|
||||
.node {
|
||||
display: grid;
|
||||
|
|
@ -240,6 +252,7 @@ header {
|
|||
.name {
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
|
||||
&:hover {
|
||||
color: @accent_2;
|
||||
|
|
@ -330,6 +343,12 @@ header {
|
|||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
#notes-version {
|
||||
margin-top: 64px;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#node-content.encrypted {
|
||||
color: #a00;
|
||||
}
|
||||
|
|
@ -352,6 +371,214 @@ header {
|
|||
}
|
||||
}
|
||||
|
||||
#markdown {
|
||||
color: #333;
|
||||
grid-area: content;
|
||||
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 8px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0px;
|
||||
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
background: #e6eeee;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #f5f5f5;
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
pre > code {
|
||||
background: unset;
|
||||
padding: 0px;
|
||||
border-radius: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
#checklist {
|
||||
grid-area: checklist;
|
||||
color: #333;
|
||||
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 8px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0px;
|
||||
|
||||
.header {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, min-content);
|
||||
align-items: center;
|
||||
grid-gap: 0 16px;
|
||||
|
||||
img {
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.header + .checklist-group.edit {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.checklist-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, min-content);
|
||||
align-items: center;
|
||||
grid-gap: 0 8px;
|
||||
|
||||
margin-top: 1em;
|
||||
margin-bottom: 8px;
|
||||
font-weight: bold;
|
||||
|
||||
.label {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.label.ok {
|
||||
color: #54b356;
|
||||
}
|
||||
|
||||
.label.error {
|
||||
color: #d13636;
|
||||
}
|
||||
|
||||
&.edit {
|
||||
margin-top: 32px;
|
||||
border-bottom: 1px solid #aaa;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
&:not(.edit) {
|
||||
.reorder { display: none; }
|
||||
img { display: none; }
|
||||
}
|
||||
|
||||
img {
|
||||
height: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.checklist-item {
|
||||
transform: translate(0, 0);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, min-content);
|
||||
grid-gap: 0 8px;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
border-bottom: 2px solid #fff;
|
||||
|
||||
&.checked {
|
||||
text-decoration: line-through;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
&.drag-target {
|
||||
border-bottom: 2px solid #71c837;
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
background-color: #fff;
|
||||
margin: 0 2px 0 0;
|
||||
font: inherit;
|
||||
color: currentColor;
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
border: 0.15em solid currentColor;
|
||||
border-radius: 0.15em;
|
||||
transform: translateY(-0.075em);
|
||||
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
|
||||
label.ok {
|
||||
color: #54b356;
|
||||
}
|
||||
|
||||
label.error {
|
||||
color: #d13636;
|
||||
}
|
||||
|
||||
input[type="checkbox"].ok {
|
||||
border: 0.15em solid #54b356;
|
||||
}
|
||||
|
||||
input[type="checkbox"].ok::before {
|
||||
box-shadow: inset 1em 1em #54b356;
|
||||
}
|
||||
|
||||
input[type="checkbox"].error {
|
||||
border: 0.15em solid #d13636;
|
||||
}
|
||||
|
||||
input[type="checkbox"].error::before {
|
||||
box-shadow: inset 1em 1em #d13636;
|
||||
}
|
||||
|
||||
input[type="checkbox"]::before {
|
||||
content: "";
|
||||
width: 0.70em;
|
||||
height: 0.70em;
|
||||
transform: scale(0);
|
||||
transition: 120ms transform ease-in-out;
|
||||
box-shadow: inset 1em 1em @checkbox_1;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked::before {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
&.edit {
|
||||
input[type="checkbox"] {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.edit) {
|
||||
.reorder {
|
||||
display: none;
|
||||
}
|
||||
img {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
height: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
label {
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================= *
|
||||
* Textarea replicates the height of an element expanding height *
|
||||
* ============================================================= */
|
||||
|
|
@ -395,7 +622,7 @@ header {
|
|||
}
|
||||
/* ============================================================= */
|
||||
|
||||
#file-section {
|
||||
#schedule-section {
|
||||
grid-area: files;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
|
|
@ -405,6 +632,25 @@ header {
|
|||
border-radius: 8px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 32px;
|
||||
color: #000;
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
#file-section {
|
||||
grid-area: schedule;
|
||||
justify-self: center;
|
||||
width: calc(100% - 32px);
|
||||
max-width: 900px;
|
||||
padding: 32px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
|
|
@ -528,6 +774,8 @@ header {
|
|||
"tree child-nodes"
|
||||
"tree name"
|
||||
"tree content"
|
||||
"tree checklist"
|
||||
"tree schedule"
|
||||
"tree files"
|
||||
"tree blank"
|
||||
;
|
||||
|
|
@ -538,10 +786,12 @@ header {
|
|||
min-content /* child-nodes */
|
||||
min-content /* name */
|
||||
min-content /* content */
|
||||
min-content /* checklist */
|
||||
min-content /* schedule */
|
||||
min-content /* files */
|
||||
1fr; /* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
}// }}}
|
||||
.layout-tree-only {// {{{
|
||||
display: grid;
|
||||
|
|
@ -554,7 +804,7 @@ header {
|
|||
min-content /* header */
|
||||
1fr; /* blank */
|
||||
color: #fff;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
|
||||
#crumbs { display: none }
|
||||
.child-nodes { display: none }
|
||||
|
|
@ -570,6 +820,8 @@ header {
|
|||
"child-nodes"
|
||||
"name"
|
||||
"content"
|
||||
"checklist"
|
||||
"schedule"
|
||||
"files"
|
||||
"blank"
|
||||
;
|
||||
|
|
@ -580,9 +832,15 @@ header {
|
|||
min-content /* child-nodes */
|
||||
min-content /* name */
|
||||
min-content /* content */
|
||||
min-content /* checklist */
|
||||
min-content /* schedule */
|
||||
min-content /* files */
|
||||
1fr; /* blank */
|
||||
#tree { display: none }
|
||||
|
||||
#checklist {
|
||||
padding: 16px;
|
||||
}
|
||||
}// }}}
|
||||
.layout-keys {
|
||||
display: grid;
|
||||
|
|
@ -606,7 +864,15 @@ header {
|
|||
#keys { display: block }
|
||||
}
|
||||
|
||||
#app {
|
||||
#app.login {
|
||||
padding-top: 64px;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: minmax(min-content, 300px);
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#app.node {
|
||||
.layout-tree();
|
||||
|
||||
&.toggle-tree {
|
||||
|
|
@ -615,8 +881,100 @@ header {
|
|||
|
||||
}
|
||||
|
||||
#profile-settings {
|
||||
color: #333;
|
||||
padding: 16px;
|
||||
|
||||
.passwords {
|
||||
display: grid;
|
||||
grid-template-columns: min-content 200px;
|
||||
grid-gap: 8px 16px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
div {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#schedule-events {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, min-content);
|
||||
grid-gap: 4px 12px;
|
||||
margin: 32px;
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
#input-text {
|
||||
border: 1px solid #000 !important;
|
||||
padding: 16px;
|
||||
width: 300px;
|
||||
|
||||
.label {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
width: 100%;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 64px 64px;
|
||||
grid-gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
#fullcalendar {
|
||||
margin: 32px;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.folder {
|
||||
.tabs {
|
||||
border-left: 1px solid #888;
|
||||
display: flex;
|
||||
|
||||
.tab {
|
||||
padding: 16px 32px;
|
||||
border-top: 1px solid #888;
|
||||
border-bottom: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
color: #444;
|
||||
background: #eee;
|
||||
cursor: pointer;
|
||||
|
||||
&.selected {
|
||||
border-bottom: none;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.hack {
|
||||
border-bottom: 1px solid #888;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 1px;
|
||||
border-left: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
border-bottom: 1px solid #888;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 932px) {
|
||||
#app {
|
||||
#app.node {
|
||||
.layout-crumbs();
|
||||
|
||||
&.toggle-tree {
|
||||
|
|
@ -630,7 +988,7 @@ header {
|
|||
justify-self: start;
|
||||
}
|
||||
|
||||
#file-section {
|
||||
#file-section, #checklist, #markdown {
|
||||
width: calc(100% - 32px);
|
||||
padding: 16px;
|
||||
margin-left: 16px;
|
||||
|
|
|
|||
31
static/less/search.less
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
@import "theme.less";
|
||||
|
||||
#search {
|
||||
padding: 16px;
|
||||
color: #333;
|
||||
|
||||
h2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.matches {
|
||||
.matched-node {
|
||||
cursor: pointer;
|
||||
margin-top: 6px;
|
||||
|
||||
&:before {
|
||||
content: "•";
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,3 +3,17 @@
|
|||
@accent_1: #abc837;
|
||||
@accent_2: #ecbf00;
|
||||
@accent_3: #c84a37;
|
||||
|
||||
@header_1: #518048;
|
||||
@header_2: #518048;
|
||||
|
||||
@checkbox_1: #666;
|
||||
|
||||
/*
|
||||
@theme_gradient: linear-gradient(to right, #009fff, #ec2f4b);
|
||||
@theme_gradient: linear-gradient(to right, #f5af19, #f12711);
|
||||
@theme_gradient: linear-gradient(to right, #fdc830, #f37335);
|
||||
@theme_gradient: linear-gradient(to right, #8a2387, #e94057, #f27121);
|
||||
@theme_gradient: linear-gradient(to right, #659999, #f4791f);
|
||||
*/
|
||||
@theme_gradient: linear-gradient(to right, #3e5151, #decba4);
|
||||
|
|
|
|||
34
user.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
func (session Session) UpdatePassword(currPass, newPass string) (ok bool, err error) {
|
||||
var result sql.Result
|
||||
var rowsAffected int64
|
||||
|
||||
result, err = db.Exec(`
|
||||
UPDATE public.user
|
||||
SET
|
||||
password = password_hash(
|
||||
/ salt in hex /
|
||||
ENCODE(gen_random_bytes(16), 'hex'),
|
||||
|
||||
/ password /
|
||||
$1::bytea
|
||||
)
|
||||
WHERE
|
||||
id = $2 AND
|
||||
password=password_hash(SUBSTRING(password FROM 1 FOR 32), $3::bytea)
|
||||
RETURNING id
|
||||
`,
|
||||
newPass,
|
||||
session.UserID,
|
||||
currPass,
|
||||
)
|
||||
|
||||
if rowsAffected, err = result.RowsAffected(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return rowsAffected > 0, nil
|
||||
}
|
||||
*/
|
||||
1
version
Normal file
|
|
@ -0,0 +1 @@
|
|||
v29
|
||||