Skip to content

Commit

Permalink
Add demo mode + various fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
enaut committed Oct 4, 2021
1 parent 7c2ce18 commit e98b468
Show file tree
Hide file tree
Showing 9 changed files with 386 additions and 345 deletions.
532 changes: 232 additions & 300 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,26 @@ ExecStart=/var/pslink/pslink runserver
[Install]
WantedBy=multi-user.target
```

### Setup a demo container

First build the standalone binary:

```bash
$ cargo make build_standalone
```

Create a temporary directory and copy the binary from above:

```bash
$ mkdir /tmp/pslink-container/
$ cp target/x86_64-unknown-linux-musl/release/pslink /tmp/pslink-container/
```

Run the container (podman is used here but docker could be used exactly the same):

```bash
$ podman run --expose 8080 -p=8080:8080 -it pslink-container ./pslink demo -i 0.0.0.0
```

Note that this is **absolutely not for a production use** and only for demo purposes as the links are **deleted on every restart**.
2 changes: 1 addition & 1 deletion app/src/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::Msg;
pub fn navigation(i18n: &I18n, base_url: &Url, user: &User) -> Node<Msg> {
// A shortcut for translating strings.
let t = move |key: &str| i18n.translate(key, None);
// Translate the wellcome message
// Translate the welcome message
let welcome = i18n.translate(
"welcome-user",
Some(&fluent_args![ "username" => user.username.clone()]),
Expand Down
21 changes: 11 additions & 10 deletions app/src/pages/list_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<T> Deref for Cached<T> {
}
}

/// There can allways be only one dialog.
/// There can always be only one dialog.
#[derive(Debug, Clone)]
enum Dialog {
EditLink {
Expand Down Expand Up @@ -150,7 +150,7 @@ pub enum Msg {
Query(QueryMsg), // Messages related to querying links
Edit(EditMsg), // Messages related to editing links
ClearAll, // Clear all messages
SetupObserver, // Make an observer for endles scroll
SetupObserver, // Make an observer for endless scroll
Observed(Vec<IntersectionObserverEntry>),
SetMessage(String), // Set a message to the user
}
Expand Down Expand Up @@ -244,7 +244,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
log!("element not yet registered! ");
};
} else {
log!("Failed to get observer!")
log!("Failed to get observer!");
};
}
}
Expand All @@ -255,13 +255,13 @@ pub fn process_query_messages(msg: QueryMsg, model: &mut Model, orders: &mut imp
match msg {
QueryMsg::Fetch => {
orders.skip(); // No need to rerender
initial_load(model, orders)
initial_load(model, orders);
}
QueryMsg::FetchAdditional => {
orders.skip(); // No need to rerender
consecutive_load(model, orders)
consecutive_load(model, orders);
}
// Default to ascending ordering but if the links are already sorted according to this collumn toggle between ascending and descending ordering.
// Default to ascending ordering but if the links are already sorted according to this column toggle between ascending and descending ordering.
QueryMsg::OrderBy(column) => {
model.formconfig.order = model.formconfig.order.as_ref().map_or_else(
|| {
Expand Down Expand Up @@ -316,7 +316,7 @@ pub fn process_query_messages(msg: QueryMsg, model: &mut Model, orders: &mut imp
QueryMsg::ReceivedAdditional(response) => {
if response.len() < model.formconfig.amount {
log!("There are no more links! ");
model.everything_loaded = true
model.everything_loaded = true;
};
let mut new_links = response
.into_iter()
Expand Down Expand Up @@ -376,7 +376,7 @@ fn load_links(orders: &mut impl Orders<Msg>, data: LinkRequestForm) {
.json(&data),
Msg::SetMessage("Failed to parse data".to_string())
);
// send the request and recieve a response
// send the request and receive a response
let response = unwrap_or_return!(
fetch(request).await,
Msg::SetMessage("Failed to send data".to_string())
Expand Down Expand Up @@ -554,7 +554,7 @@ fn delete_link(link_delta: LinkDelta, orders: &mut impl Orders<Msg>) {
.json(&link_delta),
Msg::SetMessage("serialization failed".to_string())
);
// perform the request and recieve a respnse
// perform the request and receive a response
let response =
unwrap_or_return!(fetch(request).await, Msg::Edit(EditMsg::FailedToDeleteLink));

Expand Down Expand Up @@ -746,7 +746,8 @@ fn view_link(l: &Cached<FullLink>, logged_in_user: &User) -> Node<Msg> {
C!["table_qr"],
a![
ev(Ev::Click, |event| event.stop_propagation()),
attrs![At::Href => format!["/admin/download/png/{}", &l.link.code], At::Download => true.as_at_value()],
attrs![At::Href => format!("/admin/download/png/{}", &l.link.code),
At::Download => true.as_at_value()],
raw!(&l.cache)
]
]
Expand Down
6 changes: 3 additions & 3 deletions app/src/pages/list_users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct FilterInput {
filter_input: ElRef<web_sys::HtmlInputElement>,
}

/// The message splits the contained message into messages related to querrying and messages related to editing.
/// The message splits the contained message into messages related to querying and messages related to editing.
#[derive(Clone)]
pub enum Msg {
Query(UserQueryMsg),
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn process_query_messages(msg: UserQueryMsg, model: &mut Model, orders: &mut
}
UserQueryMsg::EmailFilterChanged(s) => {
log!("Filter is: ", &s);
// FIXME: Sanitazion does not work for @
// FIXME: Sanitation does not work for @
let sanit = s.chars().filter(|x| x.is_alphanumeric()).collect();
model.formconfig.filter[UserOverviewColumns::Email].sieve = sanit;
orders.send_msg(Msg::Query(UserQueryMsg::Fetch));
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn process_user_edit_messages(
let data = model
.user_edit
.take()
.expect("A user should allways be there on save");
.expect("A user should always be there on save");
log!("Saving User: ", &data.username);
save_user(data, orders);
}
Expand Down
Loading

0 comments on commit e98b468

Please sign in to comment.