Browse Source

server -> civil-server, core -> civil-shared, wasm -> civil-wasm

master
Inderjit Gill 3 months ago
parent
commit
922ade8999
82 changed files with 209 additions and 88 deletions
  1. +0
    -1
      .gitignore
  2. +26
    -17
      Makefile
  3. +0
    -0
      civil-server/.gitignore
  4. +29
    -0
      civil-server/Cargo.lock
  5. +3
    -1
      civil-server/Cargo.toml
  6. +0
    -0
      civil-server/README.md
  7. +0
    -0
      civil-server/errors/400.html
  8. +0
    -0
      civil-server/errors/404.html
  9. +0
    -0
      civil-server/errors/500.html
  10. +42
    -0
      civil-server/src/bin/civil_note_parser.rs
  11. +0
    -0
      civil-server/src/bin/civil_server.rs
  12. +0
    -0
      civil-server/src/bin/civil_stat_collector.rs
  13. +0
    -0
      civil-server/src/db/autocomplete.rs
  14. +0
    -0
      civil-server/src/db/deck_kind.rs
  15. +0
    -0
      civil-server/src/db/decks.rs
  16. +0
    -0
      civil-server/src/db/edges.rs
  17. +0
    -0
      civil-server/src/db/ideas.rs
  18. +0
    -0
      civil-server/src/db/mod.rs
  19. +13
    -0
      civil-server/src/db/notes.rs
  20. +0
    -0
      civil-server/src/db/people.rs
  21. +0
    -0
      civil-server/src/db/pg.rs
  22. +0
    -0
      civil-server/src/db/point_kind.rs
  23. +0
    -0
      civil-server/src/db/points.rs
  24. +0
    -0
      civil-server/src/db/publications.rs
  25. +0
    -0
      civil-server/src/db/ref_kind.rs
  26. +0
    -0
      civil-server/src/db/sr.rs
  27. +0
    -0
      civil-server/src/db/stats.rs
  28. +0
    -0
      civil-server/src/db/timelines.rs
  29. +0
    -0
      civil-server/src/db/uploader.rs
  30. +0
    -0
      civil-server/src/db/users.rs
  31. +18
    -16
      civil-server/src/error.rs
  32. +0
    -0
      civil-server/src/handler/autocomplete.rs
  33. +0
    -0
      civil-server/src/handler/cmd.rs
  34. +0
    -0
      civil-server/src/handler/edges.rs
  35. +0
    -0
      civil-server/src/handler/ideas.rs
  36. +0
    -0
      civil-server/src/handler/mod.rs
  37. +0
    -0
      civil-server/src/handler/notes.rs
  38. +0
    -0
      civil-server/src/handler/people.rs
  39. +0
    -0
      civil-server/src/handler/publications.rs
  40. +0
    -0
      civil-server/src/handler/sr.rs
  41. +0
    -0
      civil-server/src/handler/timelines.rs
  42. +0
    -0
      civil-server/src/handler/ubersetup.rs
  43. +0
    -0
      civil-server/src/handler/uploader.rs
  44. +0
    -0
      civil-server/src/handler/users.rs
  45. +0
    -0
      civil-server/src/interop/autocomplete.rs
  46. +0
    -0
      civil-server/src/interop/decks.rs
  47. +0
    -0
      civil-server/src/interop/edges.rs
  48. +0
    -0
      civil-server/src/interop/ideas.rs
  49. +0
    -0
      civil-server/src/interop/mod.rs
  50. +0
    -0
      civil-server/src/interop/notes.rs
  51. +0
    -0
      civil-server/src/interop/people.rs
  52. +0
    -0
      civil-server/src/interop/points.rs
  53. +0
    -0
      civil-server/src/interop/publications.rs
  54. +0
    -0
      civil-server/src/interop/sr.rs
  55. +0
    -0
      civil-server/src/interop/stats.rs
  56. +0
    -0
      civil-server/src/interop/timelines.rs
  57. +0
    -0
      civil-server/src/interop/uploader.rs
  58. +0
    -0
      civil-server/src/interop/users.rs
  59. +1
    -0
      civil-server/src/lib.rs
  60. +25
    -0
      civil-server/src/note_parser_api.rs
  61. +0
    -0
      civil-server/src/server_api.rs
  62. +0
    -0
      civil-server/src/session.rs
  63. +0
    -0
      civil-server/src/stat_api.rs
  64. +0
    -0
      civil-shared/.gitignore
  65. +1
    -1
      civil-shared/Cargo.lock
  66. +1
    -1
      civil-shared/Cargo.toml
  67. +0
    -0
      civil-shared/rustfmt.toml
  68. +0
    -0
      civil-shared/src/compiler.rs
  69. +0
    -0
      civil-shared/src/element.rs
  70. +0
    -0
      civil-shared/src/error.rs
  71. +0
    -0
      civil-shared/src/lexer.rs
  72. +1
    -1
      civil-shared/src/lib.rs
  73. +0
    -0
      civil-shared/src/parser.rs
  74. +0
    -0
      civil-shared/src/splitter.rs
  75. +1
    -0
      civil-wasm/.gitignore
  76. +26
    -26
      civil-wasm/Cargo.lock
  77. +2
    -2
      civil-wasm/Cargo.toml
  78. +4
    -4
      civil-wasm/src/lib.rs
  79. +2
    -2
      www/.gitignore
  80. +11
    -13
      www/index.html
  81. +1
    -1
      www/js/index.js
  82. +2
    -2
      www/service-worker.js

+ 0
- 1
.gitignore View File

@ -1,3 +1,2 @@
dist
core/target
.env

+ 26
- 17
Makefile View File

@ -26,12 +26,21 @@
.PHONY: run download-images clean-dist
run:
cargo run --manifest-path server/Cargo.toml --bin civil_server
cargo run --manifest-path civil-server/Cargo.toml --bin civil_server
# collect stats on each user's content, stores the stats in the db
# this is run periodically on the server
#
run-stat-collector:
cargo run --manifest-path server/Cargo.toml --bin civil_stat_collector
cargo run --manifest-path civil-server/Cargo.toml --bin civil_stat_collector
# iterates through all the notes in the database, parsing their markup
# useful as a sanity check to make sure everything is still parseable
#
run-note_parser:
cargo run --manifest-path civil-server/Cargo.toml --bin civil_note_parser
wasm: www/wasm_bg.wasm
wasm: www/civil_wasm_bg.wasm
release: clean-dist client-dist server-dist systemd-dist wasm-dist
@ -64,17 +73,17 @@ MINIFY := $(shell command -v minify 2> /dev/null)
################################################################################
CLIENT_FILES = $(call rwildcard,www,*)
SERVER_FILES = $(call rwildcard,server/src,*) $(wildcard server/errors/*.html) server/Cargo.toml
SERVER_FILES = $(call rwildcard,civil-server/src,*) $(wildcard civil-server/errors/*.html) civil-server/Cargo.toml
SYSTEMD_FILES = $(wildcard misc/systemd/*)
WASM_FILES = $(wildcard wasm/src/*) wasm/Cargo.toml
CORE_FILES = $(wildcard core/src/*) core/Cargo.toml
WASM_FILES = $(wildcard civil-wasm/src/*) civil-wasm/Cargo.toml
SHARED_FILES = $(wildcard civil-shared/src/*) civil-shared/Cargo.toml
################################################################################
# convenient aliases for targets
################################################################################
wasm-dist: dist/www/wasm_bg.wasm
wasm-dist: dist/www/civil_wasm_bg.wasm
client-dist: dist/www/index.html
server-dist: dist/civil_server
systemd-dist: dist/systemd/isg-civil.sh
@ -83,14 +92,14 @@ systemd-dist: dist/systemd/isg-civil.sh
# targets
################################################################################
www/wasm_bg.wasm: $(WASM_FILES) $(CORE_FILES)
cargo build --manifest-path wasm/Cargo.toml --target wasm32-unknown-unknown
wasm-bindgen wasm/target/wasm32-unknown-unknown/debug/wasm.wasm --out-dir www --no-typescript --no-modules
www/civil_wasm_bg.wasm: $(WASM_FILES) $(SHARED_FILES)
cargo build --manifest-path civil-wasm/Cargo.toml --target wasm32-unknown-unknown
wasm-bindgen civil-wasm/target/wasm32-unknown-unknown/debug/civil_wasm.wasm --out-dir www --no-typescript --no-modules
dist/www/wasm_bg.wasm: $(WASM_FILES) $(CORE_FILES)
dist/www/civil_wasm_bg.wasm: $(WASM_FILES) $(SHARED_FILES)
mkdir -p $(@D)
cargo build --manifest-path wasm/Cargo.toml --release --target wasm32-unknown-unknown
wasm-bindgen wasm/target/wasm32-unknown-unknown/release/wasm.wasm --out-dir dist/www --no-typescript --no-modules
cargo build --manifest-path civil-wasm/Cargo.toml --release --target wasm32-unknown-unknown
wasm-bindgen civil-wasm/target/wasm32-unknown-unknown/release/civil_wasm.wasm --out-dir dist/www --no-typescript --no-modules
dist/www/index.html: $(CLIENT_FILES)
mkdir -p $(@D)
@ -104,11 +113,11 @@ endif
dist/civil_server: $(SERVER_FILES)
mkdir -p $(@D)
cd server && cargo build --release
cp server/target/release/civil_server dist/.
cp server/target/release/civil_stat_collector dist/.
cd civil-server && cargo build --release
cp civil-server/target/release/civil_server dist/.
cp civil-server/target/release/civil_stat_collector dist/.
cp .env.example dist/.
cp -r server/errors dist/.
cp -r civil-server/errors dist/.
dist/systemd/isg-civil.sh: $(SYSTEMD_FILES)
mkdir -p $(@D)


server/.gitignore → civil-server/.gitignore View File


server/Cargo.lock → civil-server/Cargo.lock View File


server/Cargo.toml → civil-server/Cargo.toml View File


server/README.md → civil-server/README.md View File


server/errors/400.html → civil-server/errors/400.html View File


server/errors/404.html → civil-server/errors/404.html View File


server/errors/500.html → civil-server/errors/500.html View File


+ 42
- 0
civil-server/src/bin/civil_note_parser.rs View File

@ -0,0 +1,42 @@
// Copyright (C) 2021 Inderjit Gill <email@indy.io>
// This file is part of Civil
// Civil is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Civil is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use civil;
use civil::{note_parser_api, Result};
use civil_shared;
use tracing::info;
#[actix_rt::main]
async fn main() -> Result<()> {
civil::init_dotenv();
civil::init_tracing();
let pool = civil::init_postgres_pool().await?;
info!("started parsing all note markup");
let notes = note_parser_api::get_all_notes_in_db(&pool).await?;
let mut num_elements: usize = 0;
for note in notes {
let res = civil_shared::markup_as_struct(&note.content)?;
num_elements += res.len();
}
info!("finished parsing all note markup {}", num_elements);
Ok(())
}

server/src/bin/civil_server.rs → civil-server/src/bin/civil_server.rs View File


server/src/bin/civil_stat_collector.rs → civil-server/src/bin/civil_stat_collector.rs View File


server/src/db/autocomplete.rs → civil-server/src/db/autocomplete.rs View File


server/src/db/deck_kind.rs → civil-server/src/db/deck_kind.rs View File


server/src/db/decks.rs → civil-server/src/db/decks.rs View File


server/src/db/edges.rs → civil-server/src/db/edges.rs View File


server/src/db/ideas.rs → civil-server/src/db/ideas.rs View File


server/src/db/mod.rs → civil-server/src/db/mod.rs View File


server/src/db/notes.rs → civil-server/src/db/notes.rs View File


server/src/db/people.rs → civil-server/src/db/people.rs View File


server/src/db/pg.rs → civil-server/src/db/pg.rs View File


server/src/db/point_kind.rs → civil-server/src/db/point_kind.rs View File


server/src/db/points.rs → civil-server/src/db/points.rs View File


server/src/db/publications.rs → civil-server/src/db/publications.rs View File


server/src/db/ref_kind.rs → civil-server/src/db/ref_kind.rs View File


server/src/db/sr.rs → civil-server/src/db/sr.rs View File


server/src/db/stats.rs → civil-server/src/db/stats.rs View File


server/src/db/timelines.rs → civil-server/src/db/timelines.rs View File


server/src/db/uploader.rs → civil-server/src/db/uploader.rs View File


server/src/db/users.rs → civil-server/src/db/users.rs View File


server/src/error.rs → civil-server/src/error.rs View File


server/src/handler/autocomplete.rs → civil-server/src/handler/autocomplete.rs View File


server/src/handler/cmd.rs → civil-server/src/handler/cmd.rs View File


server/src/handler/edges.rs → civil-server/src/handler/edges.rs View File


server/src/handler/ideas.rs → civil-server/src/handler/ideas.rs View File


server/src/handler/mod.rs → civil-server/src/handler/mod.rs View File


server/src/handler/notes.rs → civil-server/src/handler/notes.rs View File


server/src/handler/people.rs → civil-server/src/handler/people.rs View File


server/src/handler/publications.rs → civil-server/src/handler/publications.rs View File


server/src/handler/sr.rs → civil-server/src/handler/sr.rs View File


server/src/handler/timelines.rs → civil-server/src/handler/timelines.rs View File


server/src/handler/ubersetup.rs → civil-server/src/handler/ubersetup.rs View File


server/src/handler/uploader.rs → civil-server/src/handler/uploader.rs View File


server/src/handler/users.rs → civil-server/src/handler/users.rs View File


server/src/interop/autocomplete.rs → civil-server/src/interop/autocomplete.rs View File


server/src/interop/decks.rs → civil-server/src/interop/decks.rs View File


server/src/interop/edges.rs → civil-server/src/interop/edges.rs View File


server/src/interop/ideas.rs → civil-server/src/interop/ideas.rs View File


server/src/interop/mod.rs → civil-server/src/interop/mod.rs View File


server/src/interop/notes.rs → civil-server/src/interop/notes.rs View File


server/src/interop/people.rs → civil-server/src/interop/people.rs View File


server/src/interop/points.rs → civil-server/src/interop/points.rs View File


server/src/interop/publications.rs → civil-server/src/interop/publications.rs View File


server/src/interop/sr.rs → civil-server/src/interop/sr.rs View File


server/src/interop/stats.rs → civil-server/src/interop/stats.rs View File


server/src/interop/timelines.rs → civil-server/src/interop/timelines.rs View File


server/src/interop/uploader.rs → civil-server/src/interop/uploader.rs View File


server/src/interop/users.rs → civil-server/src/interop/users.rs View File


server/src/lib.rs → civil-server/src/lib.rs View File


+ 25
- 0
civil-server/src/note_parser_api.rs View File

@ -0,0 +1,25 @@
// Copyright (C) 2021 Inderjit Gill <email@indy.io>
// This file is part of Civil
// Civil is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Civil is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::db::notes as notes_db;
use crate::error::Result;
use crate::interop::notes::Note;
use deadpool_postgres::Pool;
pub async fn get_all_notes_in_db(db_pool: &Pool) -> Result<Vec<Note>> {
notes_db::get_all_notes_in_db(db_pool).await
}

server/src/server_api.rs → civil-server/src/server_api.rs View File


server/src/session.rs → civil-server/src/session.rs View File


server/src/stat_api.rs → civil-server/src/stat_api.rs View File


wasm/.gitignore → civil-shared/.gitignore View File


core/Cargo.lock → civil-shared/Cargo.lock View File


core/Cargo.toml → civil-shared/Cargo.toml View File


core/rustfmt.toml → civil-shared/rustfmt.toml View File


core/src/compiler.rs → civil-shared/src/compiler.rs View File


core/src/element.rs → civil-shared/src/element.rs View File


core/src/error.rs → civil-shared/src/error.rs View File


core/src/lexer.rs → civil-shared/src/lexer.rs View File


core/src/lib.rs → civil-shared/src/lib.rs View File


core/src/parser.rs → civil-shared/src/parser.rs View File


core/src/splitter.rs → civil-shared/src/splitter.rs View File


+ 1
- 0
civil-wasm/.gitignore View File

@ -0,0 +1 @@
target

wasm/Cargo.lock → civil-wasm/Cargo.lock View File


wasm/Cargo.toml → civil-wasm/Cargo.toml View File


wasm/src/lib.rs → civil-wasm/src/lib.rs View File


+ 2
- 2
www/.gitignore View File

@ -1,2 +1,2 @@
wasm.js
wasm_bg.wasm
civil_wasm.js
civil_wasm_bg.wasm

+ 11
- 13
www/index.html View File

@ -4,22 +4,20 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#494949">
<meta name="apple-mobile-web-app-title" content="Civil">
<meta name="application-name" content="Civil">
<meta name="msapplication-TileColor" content="#f5f2f0">
<meta name="theme-color" content="#f5f2f0">
<link type="text/css" rel="stylesheet" href="/civil.css" media="all" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#494949">
<meta name="apple-mobile-web-app-title" content="Civil">
<meta name="application-name" content="Civil">
<meta name="msapplication-TileColor" content="#f5f2f0">
<meta name="theme-color" content="#f5f2f0">
<!-- <link rel="stylesheet" href="/js/ext/katex/katex.min.css"> -->
<!-- <script defer src="/js/ext/katex/katex.min.js"></script> -->
<link type="text/css" rel="stylesheet" href="/civil.css" media="all" />
<script src="/wasm.js"></script>
<script src="/civil_wasm.js"></script>
<script type="module" src="/js/index.js"></script>


+ 1
- 1
www/js/index.js View File

@ -2,7 +2,7 @@ import { render } from '/lib/preact/mod.js';
import Net from '/js/Net.js';
import { App, buildInitialState } from '/js/App.js';
wasm_bindgen('/wasm_bg.wasm')
wasm_bindgen('/civil_wasm_bg.wasm')
.then(async wasm_bg => {
const { init_wasm, markup_as_struct, split_markup, graph_physics } = wasm_bindgen;


+ 2
- 2
www/service-worker.js View File

@ -62,8 +62,8 @@ var precacheConfig = [
"/js/components/StarRating.js",
"/js/components/Timelines.js",
"/wasm.js",
"/wasm_bg.wasm",
"/civil_wasm.js",
"/civil_wasm_bg.wasm",
"/lib/preact/hooks.js",
"/lib/preact/htm.js",
"/lib/preact/mod.js",


Loading…
Cancel
Save