Compare commits

...
Author SHA1 Message Date
aitzol 939c8a75d2 entrypoint 2026-09-30 04:48:19 +01:00
aitzol a3fcfffef2 entrypoint 2026-09-30 04:42:07 +01:00
aitzol 3aee14852a rust bertsio berritzea 2026-09-26 16:05:44 +01:00
aitzol 2fb52dc594 lowercase usernames 2025-06-23 11:14:03 +02:00
aitzol e2c9e8000a docker build fixes 2025-06-23 11:07:54 +02:00
aitzol 475271ca56 Merge pull request 'tables style' (#7) from tables-style into main
Reviewed-on: #7
2024-12-23 23:18:52 +01:00
aitzol bf11857d3e Merge pull request 'tables-style' (#6) from tables-style into main
Reviewed-on: #6
2024-12-22 11:13:06 +01:00
aitzol 477d5c54d9 Merge pull request 'tables-style' (#5) from tables-style into main
Reviewed-on: #5
2024-12-19 22:53:59 +01:00
14 changed files with 137 additions and 36 deletions
+1
View File
@@ -76,6 +76,7 @@ debug-mailer = []
test = [] test = []
search-lindera = ["plume-models/search-lindera"] search-lindera = ["plume-models/search-lindera"]
s3 = ["plume-models/s3"] s3 = ["plume-models/s3"]
cargo-clippy = []
[workspace] [workspace]
members = ["plume-api", "plume-cli", "plume-models", "plume-common", "plume-front", "plume-macro"] members = ["plume-api", "plume-cli", "plume-models", "plume-common", "plume-front", "plume-macro"]
+62
View File
@@ -0,0 +1,62 @@
FROM rust:1.82 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
gettext \
postgresql-client \
libpq-dev \
git \
curl \
gcc \
make \
openssl \
libssl-dev \
clang
RUN ln -s /usr/bin/python3 /usr/bin/python & \
ln -s /usr/bin/pip3 /usr/bin/pip
WORKDIR /scratch
COPY script/wasm-deps.sh .
RUN chmod a+x ./wasm-deps.sh && sleep 1 && ./wasm-deps.sh
WORKDIR /app
COPY . .
RUN echo "=== TOOLCHAIN ===" && \
rustc --version && \
cargo --version && \
rustup show && \
echo "=== TIME-CORE IN LOCK ===" && \
grep -A5 -B2 'name = "time-core"' Cargo.lock
#RUN cargo install wasm-pack
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN chmod a+x ./script/plume-front.sh && sleep 1 && ./script/plume-front.sh
RUN cargo install --locked --path ./ --force --no-default-features --features postgres
RUN cargo install --locked --path plume-cli --force --no-default-features --features postgres
#RUN cargo install --path ./ --force --no-default-features --features postgres
#RUN cargo install --path plume-cli --force --no-default-features --features postgres
RUN cargo clean
FROM debian:stable-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libpq5
WORKDIR /app
COPY --from=builder /app /app
COPY --from=builder /usr/local/cargo/bin/plm /bin/
COPY --from=builder /usr/local/cargo/bin/plume /bin/
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 755 /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["plume"]
EXPOSE 7878
+3 -2
View File
@@ -13,11 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev \ libssl-dev \
clang clang
RUN ln -s /usr/bin/python3 /usr/bin/python & \
ln -s /usr/bin/pip3 /usr/bin/pip
WORKDIR /scratch WORKDIR /scratch
COPY script/wasm-deps.sh . COPY script/wasm-deps.sh .
RUN chmod a+x ./wasm-deps.sh && sleep 1 && ./wasm-deps.sh RUN chmod a+x ./wasm-deps.sh && sleep 1 && ./wasm-deps.sh
RUN ln -s /usr/bin/python3 /usr/bin/python & \
ln -s /usr/bin/pip3 /usr/bin/pip
WORKDIR /app WORKDIR /app
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
set -eu
ENV_FILE=/app/.env
cat > "$ENV_FILE" <<EOF
BASE_URL=blog.lainoa.eus
ROCKET_SECRET_KEY=${ROCKET_SECRET_KEY}
MAIL_SERVER=smtp.lainoa.eus
MAIL_USER=aitzol
MAIL_PASSWORD=${EMAIL_PASSWORD}
POSTGRES_USER=plume
POSTGRES_DB=plume
POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
DATABASE_URL=postgres://plume:${POSTGRES_PASSWORD}@postgres:5432/plume
MIGRATION_DIRECTORY=migrations/postgres
USE_HTTPS=1
ROCKET_ADDRESS=0.0.0.0
ROCKET_PORT=7878
LDAP_ADDR=ldaps://ldap.lainoa.eus:636
LDAP_BASE_DN=cn=users,ou=groups,dc=ldap,dc=lainoa,dc=eus
LDAP_USER_NAME_ATTR=uid
LDAP_USER_MAIL_ATTR=mail
LDAP_TLS=true
LDAP_USER=cn=readonly,dc=ldap,dc=lainoa,dc=eus
LDAP_PASSWORD=${LDAP_PASSWORD}
RUST_BACTRACE=1
EOF
chmod 600 "$ENV_FILE"
exec "$@"
+1
View File
@@ -1,6 +1,7 @@
use crate::{schema::apps, Error, Result}; use crate::{schema::apps, Error, Result};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use serde_derive::Serialize;
#[derive(Clone, Queryable, Serialize)] #[derive(Clone, Queryable, Serialize)]
pub struct App { pub struct App {
+2 -1
View File
@@ -136,7 +136,8 @@ impl Comment {
|id| Comment::get(conn, id).map(|comment| comment.ap_url.unwrap_or_default()), |id| Comment::get(conn, id).map(|comment| comment.ap_url.unwrap_or_default()),
)?); )?);
note.set_published( note.set_published(
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into()) //EZABATU OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.and_utc().timestamp_nanos_opt().unwrap().into())
.expect("OffsetDateTime"), .expect("OffsetDateTime"),
); );
note.set_attributed_to(author.into_id().parse::<IriString>()?); note.set_attributed_to(author.into_id().parse::<IriString>()?);
+1
View File
@@ -5,6 +5,7 @@ use rocket::config::Limits;
use rocket::Config as RocketConfig; use rocket::Config as RocketConfig;
use std::collections::HashSet; use std::collections::HashSet;
use std::env::{self, var}; use std::env::{self, var};
use serde_derive::Serialize;
#[cfg(feature = "s3")] #[cfg(feature = "s3")]
use s3::{Bucket, Region, creds::Credentials}; use s3::{Bucket, Region, creds::Credentials};
+18 -2
View File
@@ -12,7 +12,7 @@ use activitystreams::{
prelude::*, prelude::*,
time::OffsetDateTime, time::OffsetDateTime,
}; };
use chrono::{NaiveDateTime, Utc}; use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use plume_common::{ use plume_common::{
@@ -373,7 +373,8 @@ impl Post {
}))?; }))?;
article.set_source(source); article.set_source(source);
article.set_published( article.set_published(
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into()) //EZABATU OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.timestamp_nanos_opt().unwrap().into())
OffsetDateTime::from_unix_timestamp_nanos(self.creation_date.and_utc().timestamp_nanos_opt().unwrap().into())
.expect("OffsetDateTime"), .expect("OffsetDateTime"),
); );
article.set_summary(&*self.subtitle); article.set_summary(&*self.subtitle);
@@ -752,6 +753,20 @@ impl FromId<Connection> for Post {
license, license,
// FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields // FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields
ap_url, ap_url,
creation_date: article.published().map(|published| {
let timestamp_secs = published.unix_timestamp();
let timestamp_nanos = published.unix_timestamp_nanos()
- (timestamp_secs as i128) * 1000i128 * 1000i128 * 1000i128;
DateTime::from_timestamp(
timestamp_secs,
timestamp_nanos as u32,
)
.unwrap()
.naive_utc()
}),
/*
EZABATU
creation_date: article.published().map(|published| { creation_date: article.published().map(|published| {
let timestamp_secs = published.unix_timestamp(); let timestamp_secs = published.unix_timestamp();
let timestamp_nanos = published.unix_timestamp_nanos() let timestamp_nanos = published.unix_timestamp_nanos()
@@ -762,6 +777,7 @@ impl FromId<Connection> for Post {
) )
.unwrap() .unwrap()
}), }),
*/
subtitle: article subtitle: article
.summary() .summary()
.and_then(|summary| summary.to_as_string()) .and_then(|summary| summary.to_as_string())
+2 -1
View File
@@ -93,7 +93,8 @@ macro_rules! gen_to_string {
} }
)* )*
$( $(
for val in &$self.$date { //for val in &$self.$date {
if let Some(val) = &$self.$date {
$result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce_opt(*val as i32).unwrap().format("%Y-%m-%d"))); $result.push_str(&format!("{}:{} ", stringify!($date), NaiveDate::from_num_days_from_ce_opt(*val as i32).unwrap().format("%Y-%m-%d")));
} }
)* )*
-1
View File
@@ -6,7 +6,6 @@ use crate::{
}; };
use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::ops::Deref;
pub(crate) mod query; pub(crate) mod query;
+3 -1
View File
@@ -1 +1,3 @@
nightly-2024-07-19 [toolchain]
#channel = "nightly-2025-08-01"
channel = "nightly-2024-08-30"
+1 -25
View File
@@ -21,29 +21,5 @@ EOF
echo "Detected arch: $ARCH" echo "Detected arch: $ARCH"
if [ $ARCH == "aarch64" -o $ARCH == "armv71" ] ; then if [ $ARCH == "aarch64" -o $ARCH == "armv71" ] ; then
apt-get install -y --no-install-recommends build-essential subversion ninja-build cmake apt-get install -y --no-install-recommends build-essential cmake llvm lld
mkdir -p /scratch/src
cd /scratch/src
svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_900/final/ llvm
cd /scratch/src/llvm/tools
svn co http://llvm.org/svn/llvm-project/lld/tags/RELEASE_900/final/ lld
mkdir -p /scratch/build/arm
cd /scratch/build/arm
if [ "$ARCH" == "aarch64" ] ; then
cmake -G Ninja /scratch/src/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/local/llvm \
-DLLVM_TARGETS_TO_BUILD="AArch64" \
-DLLVM_TARGET_ARCH="AArch64"
else
cmake -G Ninja /scratch/src/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/local/llvm \
-DLLVM_TARGETS_TO_BUILD="ARM" \
-DLLVM_TARGET_ARCH="ARM"
fi
ninja lld
ninja install-lld
cd ~
rm -rf /scratch
fi fi
+1 -1
View File
@@ -256,7 +256,7 @@ Then try to restart Plume.
routes::errors::server_error routes::errors::server_error
]) ])
.manage(Arc::new(Mutex::new(mail))) .manage(Arc::new(Mutex::new(mail)))
.manage::<Arc<Mutex<Vec<routes::session::ResetRequest>>>>(Arc::new(Mutex::new(vec![]))) //EZABATU 20260927 .manage::<Arc<Mutex<Vec<routes::session::ResetRequest>>>>(Arc::new(Mutex::new(vec![])))
.manage(dbpool) .manage(dbpool)
.manage(Arc::new(workpool)) .manage(Arc::new(workpool))
.manage(searcher) .manage(searcher)
+4 -2
View File
@@ -11,7 +11,7 @@ use rocket_i18n::I18n;
use std::{ use std::{
borrow::Cow, borrow::Cow,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
time::Instant, // EZABATU 20260927 time::Instant,
}; };
use tracing::warn; use tracing::warn;
use validator::{Validate, ValidationError, ValidationErrors}; use validator::{Validate, ValidationError, ValidationErrors};
@@ -54,7 +54,7 @@ pub fn create(
Ok(_) => ValidationErrors::new(), Ok(_) => ValidationErrors::new(),
Err(e) => e, Err(e) => e,
}; };
let user = User::login(&conn, &form.email_or_name, &form.password); let user = User::login(&conn, &form.email_or_name.to_lowercase(), &form.password);
let user_id = if let Ok(user) = user { let user_id = if let Ok(user) = user {
user.id.to_string() user.id.to_string()
} else { } else {
@@ -117,6 +117,7 @@ pub fn delete(mut cookies: Cookies<'_>, intl: I18n) -> Flash<Redirect> {
) )
} }
/* EZABATU 20260927
#[derive(Clone)] #[derive(Clone)]
pub struct ResetRequest { pub struct ResetRequest {
pub mail: String, pub mail: String,
@@ -129,6 +130,7 @@ impl PartialEq for ResetRequest {
self.id == other.id self.id == other.id
} }
} }
*/
#[get("/password-reset")] #[get("/password-reset")]
pub fn password_reset_request_form(conn: DbConn, rockets: PlumeRocket) -> Ructe { pub fn password_reset_request_form(conn: DbConn, rockets: PlumeRocket) -> Ructe {