diff --git a/build_main.sh b/build_main.sh new file mode 100755 index 0000000..a90f8ee --- /dev/null +++ b/build_main.sh @@ -0,0 +1 @@ +nim c -r -d:ssl,release main.nim diff --git a/code/joplin_json_utils.nim b/code/joplin_json_utils.nim new file mode 100644 index 0000000..c4a7677 --- /dev/null +++ b/code/joplin_json_utils.nim @@ -0,0 +1,12 @@ + +# Data structure for TAGS +type Tag = object + id : string + parent_id : string + title: string + +type Tags = object + items: seq[Tag] + has_more: string + + diff --git a/code/joplin_utils.nim b/code/joplin_utils.nim index 23822ea..2825d39 100644 --- a/code/joplin_utils.nim +++ b/code/joplin_utils.nim @@ -6,7 +6,7 @@ import jester from os import sleep import httpcore, net, times, strutils - +# Setup joplin_ping data type joplin_ping* = object ping_result*: seq[string] @@ -17,18 +17,22 @@ type type joplin_tags* = object id*, parent_id*, title*: seq[string] + created_time*, updated_time*, user_created_time*, user_updated_time*, is_shared*: seq[int] req*: Request # Setup joplin_notebooks data type joplin_notebooks* = object - id*, parent_id*, title*: seq[string] + id*, parent_id*, title*, share_id*, icon*: seq[string] + created_time*, updated_time*, user_created_time*, user_updated_time*, is_shared*: seq[int] req*: Request # Setup joplin_notes data type joplin_notes* = object - id*, parent_id*, title*: seq[string] + id*, parent_id*, title*, body*, author*, source_url*, source*, source_application*, application_data*, share_id*, conflict_original_id*, body_html*, base_url*: seq[string] + created_time*, updated_time*, is_conflict*, is_todo*, todo_due*, todo_completed*, user_created_time*, user_updated_time*, markup_language*, is_shared*: seq[int] + latitude*, longitude*, altitude*, order*:seq[float] req*: Request let @@ -111,6 +115,7 @@ proc get_joplin_notebooks*(token:string): Future[joplin_notebooks] {.async.} = # request joplin API for notebooks url = fmt"http://localhost:41184/folders?page={page}&token={token}" + echo("URL notebooks : ", url) var json = await client.getContent(url) # parse jason @@ -150,8 +155,9 @@ proc get_joplin_notes*(token:string): Future[joplin_notes] {.async.} = # make sure to check all pages while has_more == true: - # request joplin API for notebooks + # request joplin API for Notes url = fmt"http://localhost:41184/notes?page={page}&token={token}" + echo("URL notes : ", url) var json = await client.getContent(url) # parse jason @@ -194,6 +200,7 @@ proc get_joplin_tags*(token:string): Future[joplin_tags] {.async.} = # request joplin API for notebooks url = fmt"http://localhost:41184/tags?page={page}&token={token}" + echo("URL tags : ", url) var json = await client.getContent(url) # parse jason @@ -217,3 +224,52 @@ proc get_joplin_tags*(token:string): Future[joplin_tags] {.async.} = return j_tags + +# proc get_joplin_tags_json*(token:string): Future[] {.async.} = + +# # url = fmt"http://localhost:41184/notes/{id}?fields=id,parent_id,title,body,created_time,updated_time,is_conflict,latitude,longitude,altitude,author,source_url,is_todo,todo_due,todo_completed,source,source_application,application_data,order,user_created_time,user_updated_time,encryption_cipher_text,encryption_applied,markup_language,is_shared,share_id,conflict_original_id,master_key_id&token={token}" + +# # url = fmt"http://localhost:41184/tags/{id}?fields=id,parent_id,title,created_time,updated_time,user_created_time,user_updated_time,is_shared&token={token}" + +# # http://localhost:41184/tags?token=e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f + +# # Variables +# var j_tags: joplin_tags +# var has_more: bool = true +# var page: int = 1 +# var url: string +# var client = newAsyncHttpClient() +# var pingCheck: joplin_ping +# pingCheck = waitFor ping_joplin(token) + + +# # check the joplin status befor query +# if pingCheck.ping_status: + +# # make sure to check all pages +# while has_more == true: + +# # request joplin API for notebooks +# url = fmt"http://localhost:41184/tags?page={page}&token={token}" +# echo("URL tags : ", url) +# var json = await client.getContent(url) + +# # parse jason +# let joplin_tags_Json = parseJson(json) + +# # valider qu'il n'y a plus de page +# if not joplin_tags_Json["has_more"].getBool: +# has_more = false + +# # store json info into an object +# var count: int = 1 +# for nb in joplin_tags_Json["items"]: +# echo nb["id"].getstr +# echo nb["parent_id"].getstr +# echo nb["title"].getstr +# count += 1 + +# # aller à la page suivante +# page += 1 + + diff --git a/config.nims b/config.nims new file mode 100644 index 0000000..669bcf6 --- /dev/null +++ b/config.nims @@ -0,0 +1,5 @@ +switch("d","release") +switch("d","ssl") +# --threads:on +--opt:size +switch("passL","-s") \ No newline at end of file diff --git a/main.nim b/main.nim index f590b5b..c437877 100644 --- a/main.nim +++ b/main.nim @@ -9,7 +9,7 @@ import parsecfg # Parse CFG (config) files import strutils # Basic functions import times # Time and date import uri # We need to encode urls: encodeUrl() - +import std/json import code/database_utils # Utils used in the database import code/password_utils # Our file with password utils @@ -321,6 +321,13 @@ routes: createTFD() resp test_viewtree(c) + get "/test_tags_json": + createTFD() + var tags: JsonNodeObj + + +# http://localhost:41184/notes/77ec1bfbaccd4708a9f649f42896f437&token=e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f +# http://localhost:41184/notes/77ec1bfbaccd4708a9f649f42896f437?fields=id,parent_id,title,body,created_time,updated_time,is_conflict,latitude,longitude,altitude,author,source_url,is_todo,todo_due,todo_completed,source,source_application,application_data,order,user_created_time,user_updated_time,encryption_cipher_text,encryption_applied,markup_language,is_shared,share_id,conflict_original_id,master_key_id&token=e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f # # ## # # END TESTS SECTION ## diff --git a/nimweb.code-workspace b/nimweb.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/nimweb.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/public/css/styles.css b/public/css/styles.css index f0d2c94..e41d00a 100755 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -22,15 +22,18 @@ } -body { +html, body { margin: 0; font-family: Poppins-Regular, sans-serif; + height:100%; } *, *::before, *::after { box-sizing: border-box; + margin: 0; + padding: 0; } a { @@ -51,11 +54,11 @@ a { --light-gray: rgb(144, 144, 144); --medium-gray: rgb(96, 96, 96); --dark-gray: rgb(13, 13, 13); - --header-height: 40px; --animation-duration: 200ms; --animation-timing-curve: ease-in-out; --blue-joplin-color: #0053b8; --light-blue-joplin-color: rgb(237, 241, 243); + --header-height: 50px; } .header { @@ -85,6 +88,7 @@ a { float: left; padding: 10px; height: calc(100vh - var(--header-height)); + /* height: auto; */ /* flex: 50%; */ width: 100%; } @@ -92,8 +96,8 @@ a { .column .scrollbar { /* margin-left: 30px; */ /* float: left; */ - height: 950px; - /* width: 300px; */ + /* min-height: 100px; */ + height: 800px; background: #fff; overflow-y: scroll; /* margin-bottom: 25px; */ @@ -202,6 +206,7 @@ a { .container { display: flex; + height: 94%; } .vertical-center { @@ -215,7 +220,16 @@ a { } .content { - margin: 1rem; + /* margin: 1rem; */ + width: 1200px; + min-height: 100px; + height: auto; + margin: 80px auto 0px auto; + /* background-color: black; */ + padding: 10px 10px; + display:table; + overflow:hidden; + height:100%; } .sidebar-list { @@ -300,7 +314,7 @@ a { } .sidebar.open .top-sidebar { - height: 140px; + height: 150px; } .sidebar .top-sidebar .hidden-sidebar { diff --git a/test/oop_example b/test/oop_example deleted file mode 100755 index 2fcc3db..0000000 Binary files a/test/oop_example and /dev/null differ diff --git a/test/oop_example.nim b/test/oop_example.nim deleted file mode 100644 index 11a16c8..0000000 --- a/test/oop_example.nim +++ /dev/null @@ -1,33 +0,0 @@ -# type -# Notebook = object -# id: string -# title: string - -# var notebooks = newSeq[Notebook]() -# notebooks.add(Notebook(id:"12345", title: "un notebook titre")) - -# echo notebooks - - - -type - Notebook2 = ref object of RootObj - id: seq[string] - title: seq[string] - Notebooks = ref object of Notebook2 - nb_list: seq[int] - -var nb: Notebooks - -# nb.add(Notebook2(id:"123456", title: "mon titre")) - -# nb.id.add("toto") -# nb.title.add("tata") -# nb.nb_list.add(0) - - -echo nb.id -echo nb.title -echo nb.nb_list - - diff --git a/test/oop_example2 b/test/oop_example2 deleted file mode 100755 index d027e31..0000000 Binary files a/test/oop_example2 and /dev/null differ diff --git a/test/oop_example2.nim b/test/oop_example2.nim deleted file mode 100644 index 093c1ff..0000000 --- a/test/oop_example2.nim +++ /dev/null @@ -1,26 +0,0 @@ -type - Node = ref object of RootObj - value: string - active: bool - -type - NumNode = ref object of Node - -type - BinOp = ref object of Node - left, op, right: string - -var numnum = NumNode(value: "3", active: true) - -echo numnum[] -# > (value: "3", active: true) - -var add = BinOp( - left: "7", - op: "+", - right: "9", - active: true -) - -echo add[] -# > (left: "7", op: "+", right: "9", value: "", active: true)) \ No newline at end of file diff --git a/test/testJson b/test/testJson deleted file mode 100755 index 8b882ae..0000000 Binary files a/test/testJson and /dev/null differ diff --git a/test/testJson.nim b/test/testJson.nim deleted file mode 100644 index adab464..0000000 --- a/test/testJson.nim +++ /dev/null @@ -1,84 +0,0 @@ -import std/[asyncdispatch, httpclient] -import std/json -import std/options -import std/strformat -import jester - -# type -# joplin_notebooks* = object -# id: seq[string] -# parent_id: seq[string] -# title: seq[string] - - -# proc get_joplin_notebooks*(): Future[joplin_notebooks] {.async.} = -# var j_nb: joplin_notebooks -# var count = 0 -# var client = newAsyncHttpClient() -# var json = await client.getContent("http://localhost:41184/folders?token=e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f") - -# let joplin_notebooks_Json = parseJson(json) - -# for nb in joplin_notebooks_Json["items"]: -# j_nb.id.add(nb["id"].getstr) -# j_nb.parent_id.add(nb["parent_id"].getstr) -# j_nb.title.add(nb["title"].getstr) -# count += 1 - -# echo joplin_notebooks_Json["has_more"] - -# return j_nb - - -# Setup user data -type - joplin_notebooks* = object - id*, parent_id*, title*: seq[string] - req*: Request - -proc get_joplin_notebooks*(token:string): Future[joplin_notebooks] {.async.} = - - # Variables - var j_nb: joplin_notebooks - var has_more: bool = true - var page: int = 1 - var url: string - var client = newAsyncHttpClient() - - # make sure to check all pages - while has_more == true: - - # request joplin API for notebooks - url = fmt"http://localhost:41184/folders?page={page}&token={token}" - var json = await client.getContent(url) - - # parse jason - let joplin_notebooks_Json = parseJson(json) - - # valider qu'il n'y a plus de page - if not joplin_notebooks_Json["has_more"].getBool: - has_more = false - - # store json info into an object - var count: int = 1 - for nb in joplin_notebooks_Json["items"]: - j_nb.id.add(nb["id"].getstr) - j_nb.parent_id.add(nb["parent_id"].getstr) - j_nb.title.add(nb["title"].getstr) - count += 1 - - # aller à la page suivante - page += 1 - - return j_nb - - -# var all_notebooks = "" -var nb: joplin_notebooks -nb = waitFor get_joplin_notebooks("e5f6644fbf6a97ddc55648dae72b11caecda6c6642d8ce0d3b20129b89b196385737eb908923542c3343649ebbf865b55bda031ab4c3a16edc7723ef2ad77d8f") -# echo nb.title[1] - -for i in nb.title: - echo i - -echo nb.title \ No newline at end of file diff --git a/tmpl/tests/test_homepage.tmpl b/tmpl/tests/test_homepage.tmpl index 744c156..9efdab9 100644 --- a/tmpl/tests/test_homepage.tmpl +++ b/tmpl/tests/test_homepage.tmpl @@ -14,6 +14,7 @@

TEST Home Page

+

The newJoplin Homepage

Test ping Joplin

Test joplin Notebooks

Test Joplin Notes