chore: rename gists to gitpad

master
Aravinth Manivannan 2 years ago
parent 604d887164
commit b7fe7ea5d5
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88

@ -48,7 +48,7 @@ jobs:
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# - name: Login to DockerHub
# if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
# if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
@ -78,7 +78,7 @@ jobs:
# run: make docker
#
# - name: publish docker images
# if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
# if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
# run: make docker-publish
- name: run migrations
@ -97,7 +97,7 @@ jobs:
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
- name: generate documentation
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
run: make doc
env:
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
@ -105,7 +105,7 @@ jobs:
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
- name: Deploy to GitHub Pages
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gitpad'
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

313
Cargo.lock generated

@ -231,7 +231,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
@ -243,7 +243,7 @@ dependencies = [
"cfg-if",
"cipher",
"cpufeatures",
"opaque-debug",
"opaque-debug 0.3.0",
]
[[package]]
@ -410,13 +410,25 @@ dependencies = [
"constant_time_eq",
]
[[package]]
name = "block-buffer"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.12.4",
]
[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
@ -425,7 +437,16 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
name = "block-padding"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
dependencies = [
"byte-tools",
]
[[package]]
@ -449,12 +470,27 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"memchr",
]
[[package]]
name = "bumpalo"
version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "byteorder"
version = "1.4.3"
@ -497,7 +533,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
@ -621,7 +657,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4600d695eb3f6ce1cd44e6e291adceb2cc3ab12f20a33777ecd0bf6eba34e06"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
@ -630,7 +666,7 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
dependencies = [
"generic-array",
"generic-array 0.14.5",
"subtle",
]
@ -752,13 +788,22 @@ dependencies = [
"syn",
]
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array 0.12.4",
]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array",
"generic-array 0.14.5",
]
[[package]]
@ -835,6 +880,12 @@ dependencies = [
"termcolor",
]
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "firestorm"
version = "0.5.0"
@ -991,6 +1042,15 @@ dependencies = [
"slab",
]
[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
version = "0.14.5"
@ -1029,12 +1089,27 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99"
dependencies = [
"opaque-debug",
"opaque-debug 0.3.0",
"polyval",
]
[[package]]
name = "gists"
name = "git2"
version = "0.13.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6"
dependencies = [
"bitflags",
"libc",
"libgit2-sys",
"log",
"openssl-probe",
"openssl-sys",
"url",
]
[[package]]
name = "gitpad"
version = "0.1.0"
dependencies = [
"actix-auth-middleware",
@ -1060,6 +1135,7 @@ dependencies = [
"serde 1.0.136",
"serde_json",
"sqlx",
"tera",
"tokio",
"url",
"urlencoding",
@ -1067,18 +1143,27 @@ dependencies = [
]
[[package]]
name = "git2"
version = "0.13.25"
name = "globset"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6"
checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd"
dependencies = [
"bitflags",
"libc",
"libgit2-sys",
"aho-corasick",
"bstr",
"fnv",
"log",
"openssl-probe",
"openssl-sys",
"url",
"regex",
]
[[package]]
name = "globwalk"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
dependencies = [
"bitflags",
"ignore",
"walkdir",
]
[[package]]
@ -1239,6 +1324,24 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed"
[[package]]
name = "ignore"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d"
dependencies = [
"crossbeam-utils",
"globset",
"lazy_static",
"log",
"memchr",
"regex",
"same-file",
"thread_local",
"walkdir",
"winapi-util",
]
[[package]]
name = "indexmap"
version = "1.8.0"
@ -1467,7 +1570,7 @@ checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug",
"opaque-debug 0.3.0",
]
[[package]]
@ -1634,6 +1737,12 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "opaque-debug"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "opaque-debug"
version = "0.3.0"
@ -1696,6 +1805,49 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pest"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
dependencies = [
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pest_meta"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [
"maplit",
"pest",
"sha-1 0.8.2",
]
[[package]]
name = "phf"
version = "0.8.0"
@ -1789,7 +1941,7 @@ checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
dependencies = [
"cfg-if",
"cpufeatures",
"opaque-debug",
"opaque-debug 0.3.0",
"universal-hash",
]
@ -2076,6 +2228,15 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
@ -2175,6 +2336,18 @@ dependencies = [
"serde 1.0.136",
]
[[package]]
name = "sha-1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer 0.7.3",
"digest 0.8.1",
"fake-simd",
"opaque-debug 0.2.3",
]
[[package]]
name = "sha-1"
version = "0.9.8"
@ -2185,7 +2358,7 @@ dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.9.0",
"opaque-debug",
"opaque-debug 0.3.0",
]
[[package]]
@ -2224,7 +2397,7 @@ dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.9.0",
"opaque-debug",
"opaque-debug 0.3.0",
]
[[package]]
@ -2536,6 +2709,22 @@ dependencies = [
"utf-8",
]
[[package]]
name = "tera"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3cac831b615c25bcef632d1cabf864fa05813baad3d526829db18eb70e8b58d"
dependencies = [
"globwalk",
"lazy_static",
"pest",
"pest_derive",
"regex",
"serde 1.0.136",
"serde_json",
"unic-segment",
]
[[package]]
name = "termcolor"
version = "1.1.2"
@ -2565,6 +2754,15 @@ dependencies = [
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.1.43"
@ -2735,6 +2933,62 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "ucd-trie"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unic-char-property"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"
dependencies = [
"unic-char-range",
]
[[package]]
name = "unic-char-range"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"
[[package]]
name = "unic-common"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"
[[package]]
name = "unic-segment"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23"
dependencies = [
"unic-ucd-segment",
]
[[package]]
name = "unic-ucd-segment"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700"
dependencies = [
"unic-char-property",
"unic-char-range",
"unic-ucd-version",
]
[[package]]
name = "unic-ucd-version"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"
dependencies = [
"unic-common",
]
[[package]]
name = "unicode-bidi"
version = "0.3.7"
@ -2774,7 +3028,7 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
dependencies = [
"generic-array",
"generic-array 0.14.5",
"subtle",
]
@ -2869,6 +3123,17 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"

@ -1,12 +1,12 @@
[package]
name = "gists"
name = "gitpad"
description = "Self-Hosted GitHub Gists"
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/realaravinth/gists"
repository = "https://github.com/realaravinth/gists"
documentation = "https://github.con/realaravinth/gists"
readme = "https://github.com/realaravinth/gists/blob/master/README.md"
homepage = "https://github.com/realaravinth/gitpad"
repository = "https://github.com/realaravinth/gitpad"
documentation = "https://github.con/realaravinth/gitpad"
readme = "https://github.com/realaravinth/gitpad/blob/master/README.md"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]
build = "build.rs"
@ -48,6 +48,7 @@ url = "2.2"
urlencoding = "2.1.0"
validator = { version = "0.14.0", features = ["derive"] }
num_enum = "0.5.6"
tera = { version = "1.15.0", default-features = false}
[dev-dependencies]
actix-rt = "2"

@ -18,11 +18,11 @@ doc: ## Prepare documentation
cargo doc --no-deps --workspace --all-features
#docker: ## Build docker images
# docker build -t realaravinth/gists:master -t realaravinth/gists:latest .
# docker build -t realaravinth/gitpad:master -t realaravinth/gitpad:latest .
#
#docker-publish: docker ## Build and publish docker images
# docker push realaravinth/gists:master
# docker push realaravinth/gists:latest
# docker push realaravinth/gitpad:master
# docker push realaravinth/gitpad:latest
lint: ## Lint codebase
cargo fmt -v --all -- --emit files
@ -39,7 +39,7 @@ migrate: ## run migrations
cd database/migrator && cargo run
sqlx-offline-data: ## prepare sqlx offline data
cargo sqlx prepare --database-url=${POSTGRES_DATABASE_URL} -- --bin gists \
cargo sqlx prepare --database-url=${POSTGRES_DATABASE_URL} -- --bin gitpad \
--all-features
test: migrate ## Run tests

@ -1,14 +1,14 @@
<div align="center">
<h1> Gists </h1>
<h1> GitPad </h1>
<p>
**Self-Hosted GitHub Gists**
</p>
[![Build](https://github.com/realaravinth/gists/actions/workflows/linux.yml/badge.svg)](https://github.com/realaravinth/gists/actions/workflows/linux.yml)
[![dependency status](https://deps.rs/repo/github/realaravinth/gists/status.svg)](https://deps.rs/repo/github/realaravinth/gists)
[![codecov](https://codecov.io/gh/realaravinth/gists/branch/master/graph/badge.svg)](https://codecov.io/gh/realaravinth/gists)
[![Build](https://github.com/realaravinth/gitpad/actions/workflows/linux.yml/badge.svg)](https://github.com/realaravinth/gitpad/actions/workflows/linux.yml)
[![dependency status](https://deps.rs/repo/github/realaravinth/gitpad/status.svg)](https://deps.rs/repo/github/realaravinth/gitpad)
[![codecov](https://codecov.io/gh/realaravinth/gitpad/branch/master/graph/badge.svg)](https://codecov.io/gh/realaravinth/gitpad)
</div>
@ -34,4 +34,4 @@ can rival GitHub Gists.
1. All configuration is done through
[./config/default.toml](./config/default.toml)(can be moved to
`/etc/gists/config.toml`).
`/etc/gitpad/config.toml`).

@ -1,5 +1,5 @@
log = "info" # possible values: "info", "warn", "trace", "error", "debug"
source_code = "https://github.com/realaravinth/gists"
source_code = "https://github.com/realaravinth/gitpad"
allow_registration = true # allow registration on server
allow_demo = true # allow demo on server
@ -33,4 +33,4 @@ database_type = "postgres"
[repository]
root = "/tmp/gists.batsense.net"
root = "/tmp/gitpad.batsense.net"

@ -2,10 +2,10 @@
name = "db-core"
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/realaravinth/gists"
repository = "https://github.com/realaravinth/gists"
documentation = "https://github.con/realaravinth/gists"
readme = "https://github.com/realaravinth/gists/blob/master/README.md"
homepage = "https://github.com/realaravinth/gitpad"
repository = "https://github.com/realaravinth/gitpad"
documentation = "https://github.con/realaravinth/gitpad"
readme = "https://github.com/realaravinth/gitpad/blob/master/README.md"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]

@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#![warn(missing_docs)]
//! # `gists` database operations
//! # `gitpad` database operations
//!
//! Traits and datastructures used in gists to interact with database.
//! Traits and datastructures used in gitpad to interact with database.
//!
//! To use an unsupported database with gists, traits present within this crate should be
//! To use an unsupported database with gitpad, traits present within this crate should be
//! implemented.
//!
//!
@ -220,7 +220,7 @@ pub struct UpdateUsernamePayload<'a> {
use dev::*;
/// foo
#[async_trait]
pub trait GistDatabase: std::marker::Send + std::marker::Sync + CloneGistDatabase {
pub trait GPDatabse: std::marker::Send + std::marker::Sync + CloneGPDatabse {
/// Update email of specified user in database
async fn update_email(&self, payload: &UpdateEmailPayload) -> DBResult<()>;
/// Update password of specified user in database
@ -282,7 +282,7 @@ pub trait GistDatabase: std::marker::Send + std::marker::Sync + CloneGistDatabas
}
#[async_trait]
impl GistDatabase for Box<dyn GistDatabase> {
impl GPDatabse for Box<dyn GPDatabse> {
async fn update_email(&self, payload: &UpdateEmailPayload) -> DBResult<()> {
(**self).update_email(payload).await
}
@ -385,22 +385,22 @@ impl GistDatabase for Box<dyn GistDatabase> {
}
}
/// Trait to clone GistDatabase
pub trait CloneGistDatabase {
/// Trait to clone GPDatabse
pub trait CloneGPDatabse {
/// clone DB
fn clone_db(&self) -> Box<dyn GistDatabase>;
fn clone_db(&self) -> Box<dyn GPDatabse>;
}
impl<T> CloneGistDatabase for T
impl<T> CloneGPDatabse for T
where
T: GistDatabase + Clone + 'static,
T: GPDatabse + Clone + 'static,
{
fn clone_db(&self) -> Box<dyn GistDatabase> {
fn clone_db(&self) -> Box<dyn GPDatabse> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn GistDatabase> {
impl Clone for Box<dyn GPDatabse> {
fn clone(&self) -> Self {
(**self).clone_db()
}

@ -34,7 +34,7 @@ pub trait GetConnection {
#[async_trait]
pub trait Connect {
/// database specific pool-type
type Pool: GistDatabase;
type Pool: GPDatabse;
/// database specific error-type
/// create connection pool
async fn connect(self) -> DBResult<Self::Pool>;
@ -42,7 +42,7 @@ pub trait Connect {
/// database migrations
#[async_trait]
pub trait Migrate: GistDatabase {
pub trait Migrate: GPDatabse {
/// database specific error-type
/// run migrations
async fn migrate(&self) -> DBResult<()>;

@ -18,7 +18,7 @@
use crate::prelude::*;
/// test email registration implementation
pub async fn email_register_works<T: GistDatabase>(
pub async fn email_register_works<T: GPDatabse>(
db: &T,
email: &str,
username: &str,
@ -56,7 +56,7 @@ pub async fn email_register_works<T: GistDatabase>(
}
/// test if all visibility modes are available on database
pub async fn visibility_works<T: GistDatabase>(db: &T) {
pub async fn visibility_works<T: GPDatabse>(db: &T) {
for p in [
GistVisibility::Public,
GistVisibility::Unlisted,
@ -70,7 +70,7 @@ pub async fn visibility_works<T: GistDatabase>(db: &T) {
}
/// test all gist methods
pub async fn gists_work<T: GistDatabase>(
pub async fn gists_work<T: GPDatabse>(
db: &T,
username: &str,
password: &str,
@ -219,7 +219,7 @@ pub async fn gists_work<T: GistDatabase>(
}
/// test username registration implementation
pub async fn username_register_works<T: GistDatabase>(
pub async fn username_register_works<T: GPDatabse>(
db: &T,
username: &str,
password: &str,
@ -251,7 +251,7 @@ pub async fn username_register_works<T: GistDatabase>(
}
/// test duplicate secret errors
pub async fn duplicate_secret_guard_works<T: GistDatabase>(
pub async fn duplicate_secret_guard_works<T: GPDatabse>(
db: &T,
username: &str,
password: &str,
@ -288,7 +288,7 @@ pub async fn duplicate_secret_guard_works<T: GistDatabase>(
/// check if duplicate username and duplicate email guards are working on update workflows
#[allow(clippy::too_many_arguments)]
pub async fn duplicate_username_and_email<T: GistDatabase>(
pub async fn duplicate_username_and_email<T: GPDatabse>(
db: &T,
username: &str,
fresh_username: &str,

@ -2,10 +2,10 @@
name = "db-sqlx-postgres"
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/realaravinth/gists"
repository = "https://github.com/realaravinth/gists"
documentation = "https://github.con/realaravinth/gists"
readme = "https://github.com/realaravinth/gists/blob/master/README.md"
homepage = "https://github.com/realaravinth/gitpad"
repository = "https://github.com/realaravinth/gitpad"
documentation = "https://github.con/realaravinth/gitpad"
readme = "https://github.com/realaravinth/gitpad/blob/master/README.md"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]
include = ["./mgrations/"]

@ -17,7 +17,7 @@
#![deny(missing_docs)]
//! # `libadmin` database operations implemented using sqlx postgres
//!
//! [`GistDatabase`](GistDatabase) is implemented on [Database].
//! [`GPDatabse`](GPDatabse) is implemented on [Database].
use std::str::FromStr;
use db_core::dev::*;
@ -102,7 +102,7 @@ impl Migrate for Database {
}
#[async_trait]
impl GistDatabase for Database {
impl GPDatabse for Database {
async fn email_login(&self, email: &str) -> DBResult<Creds> {
sqlx::query_as!(
Creds,

@ -2,10 +2,10 @@
name = "db-sqlx-sqlite"
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/realaravinth/gists"
repository = "https://github.com/realaravinth/gists"
documentation = "https://github.con/realaravinth/gists"
readme = "https://github.com/realaravinth/gists/blob/master/README.md"
homepage = "https://github.com/realaravinth/gitpad"
repository = "https://github.com/realaravinth/gitpad"
documentation = "https://github.con/realaravinth/gitpad"
readme = "https://github.com/realaravinth/gitpad/blob/master/README.md"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]
include = ["./mgrations/"]

@ -89,7 +89,7 @@ impl Migrate for Database {
}
#[async_trait]
impl GistDatabase for Database {
impl GPDatabse for Database {
async fn email_login(&self, email: &str) -> DBResult<Creds> {
sqlx::query_as!(
Creds,

@ -2,6 +2,12 @@
name = "migrator"
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/realaravinth/gitpad"
repository = "https://github.com/realaravinth/gitpad"
documentation = "https://github.con/realaravinth/gitpad"
readme = "https://github.com/realaravinth/gitpad/blob/master/README.md"
license = "AGPLv3 or later version"
authors = ["realaravinth <realaravinth@batsense.net>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -57,7 +57,7 @@ pub struct Password {
impl Data {
/// Log in method. Returns `Ok(())` when user is authenticated and errors when authentication
/// fails
pub async fn login<T: GistDatabase>(&self, db: &T, payload: &Login) -> ServiceResult<String> {
pub async fn login<T: GPDatabse>(&self, db: &T, payload: &Login) -> ServiceResult<String> {
use argon2_creds::Config;
let verify = |stored: &str, received: &str| {
@ -80,7 +80,7 @@ impl Data {
}
/// register new user
pub async fn register<T: GistDatabase>(&self, db: &T, payload: &Register) -> ServiceResult<()> {
pub async fn register<T: GPDatabse>(&self, db: &T, payload: &Register) -> ServiceResult<()> {
if !self.settings.allow_registration {
return Err(ServiceError::ClosedForRegistration);
}

@ -50,7 +50,7 @@ pub enum GitFileMode {
Dir = 0o40000,
/// Deprecated represent non-executable files with the group writable bit set. This mode was
/// supported by the first versions of git, but it has been deprecated nowadays. This
/// library(github.com/go-git/go-git uses it, not realaravinth/gists at the moment) uses them
/// library(github.com/go-git/go-git uses it, not realaravinth/gitpad at the moment) uses them
/// internally, so you can read old packfiles, but will treat them as Regulars when interfacing
/// with the outside world. This is the standard git behaviour.
Deprecated = 0o100664,
@ -143,7 +143,7 @@ pub enum FileType {
}
impl Data {
pub async fn new_gist<T: GistDatabase>(
pub async fn new_gist<T: GPDatabse>(
&self,
db: &T,
msg: &CreateGist<'_>,
@ -185,7 +185,7 @@ impl Data {
Path::new(&self.settings.repository.root).join(gist_id)
}
pub async fn write_file<T: GistDatabase>(
pub async fn write_file<T: GPDatabse>(
&self,
_db: &T,
gist_id: GistID<'_>,
@ -256,7 +256,7 @@ impl Data {
/// For example, a read request for "foo bar.md" will fail even if that file is present
/// in the repository. However, it will succeed if the output of [escape_spaces] is
/// used in the request.
pub async fn read_file<T: GistDatabase>(
pub async fn read_file<T: GPDatabse>(
&self,
_db: &T,
gist_id: GistID<'_>,
@ -334,7 +334,7 @@ pub mod tests {
use crate::tests::*;
impl Data {
pub async fn gist_created_test_helper<T: GistDatabase>(
pub async fn gist_created_test_helper<T: GPDatabse>(
&self,
db: &T,
gist_id: &str,
@ -348,7 +348,7 @@ pub mod tests {
assert_eq!(db.get_gist(gist_id).await.unwrap().owner, owner);
}
pub async fn gist_files_written_helper<T: GistDatabase>(
pub async fn gist_files_written_helper<T: GPDatabse>(
&self,
db: &T,
gist_id: &str,

@ -16,7 +16,7 @@
*/
use std::sync::Arc;
use db_core::GistDatabase;
use db_core::GPDatabse;
use crate::api::v1::auth::{Login, Register};
use crate::errors::*;
@ -35,7 +35,7 @@ async fn sqlite_auth_works() {
auth_works(data, &db).await;
}
async fn auth_works(data: Arc<Data>, db: &Box<dyn GistDatabase>) {
async fn auth_works(data: Arc<Data>, db: &Box<dyn GPDatabse>) {
const NAME: &str = "testuser";
const PASSWORD: &str = "longpassword";
const EMAIL: &str = "testuser1@a.com";

@ -17,7 +17,7 @@
use crate::settings::Settings;
use db_core::prelude::*;
pub type BoxDB = Box<dyn GistDatabase>;
pub type BoxDB = Box<dyn GPDatabse>;
pub mod pg {

@ -48,7 +48,7 @@ pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");
pub const PKG_HOMEPAGE: &str = env!("CARGO_PKG_HOMEPAGE");
pub type AppData = WebData<Arc<data::Data>>;
pub type DB = WebData<Box<dyn db_core::GistDatabase>>;
pub type DB = WebData<Box<dyn db_core::GPDatabse>>;
#[cfg(not(tarpaulin_include))]
#[actix_web::main]

@ -159,9 +159,9 @@ impl Settings {
.expect("Couldn't get the number of CPUs");
const CURRENT_DIR: &str = "./config/default.toml";
const ETC: &str = "/etc/gists/config.toml";
const ETC: &str = "/etc/gitpad/config.toml";
if let Ok(path) = env::var("GIST_CONFIG") {
if let Ok(path) = env::var("GITPAD_CONFIG") {
s.merge(File::with_name(&path))?;
} else if Path::new(CURRENT_DIR).exists() {
// merging default config from file
@ -172,7 +172,7 @@ impl Settings {
log::warn!("configuration file not found");
}
s.merge(Environment::with_prefix("GISTS").separator("__"))?;
s.merge(Environment::with_prefix("GITPAD").separator("__"))?;
check_url(&s);

Loading…
Cancel
Save