From df280431c2f41dc57aeab3575c808e76bebd36d6 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Wed, 7 Feb 2024 08:23:51 +0000 Subject: [PATCH 01/19] Deprecate app public pages --- thoth-app-server/src/lib.rs | 72 ++++----- thoth-app/browserconfig.xml | 2 +- thoth-app/css/thoth.css | 23 +++ thoth-app/index.html | 34 ++--- thoth-app/main.js | 2 +- thoth-app/manifest.json | 12 +- thoth-app/src/component/about.rs | 50 ------- thoth-app/src/component/catalogue.rs | 215 --------------------------- thoth-app/src/component/hero.rs | 94 ------------ thoth-app/src/component/mod.rs | 3 - thoth-app/src/component/navbar.rs | 70 +-------- thoth-app/src/component/root.rs | 18 +-- thoth-app/src/route.rs | 2 - thoth-app/src/service/version.rs | 2 +- 14 files changed, 90 insertions(+), 509 deletions(-) delete mode 100644 thoth-app/src/component/about.rs delete mode 100644 thoth-app/src/component/catalogue.rs delete mode 100644 thoth-app/src/component/hero.rs diff --git a/thoth-app-server/src/lib.rs b/thoth-app-server/src/lib.rs index 46b70fcc..02b4dedc 100644 --- a/thoth-app-server/src/lib.rs +++ b/thoth-app-server/src/lib.rs @@ -26,42 +26,42 @@ macro_rules! static_files { } static_files! { - (JS, js_file) => ("../static/pkg/thoth_app.js", "/thoth_app.js", "application/javascript"), - (WASM, wasm_file) => ("../static/pkg/thoth_app_bg.wasm", "/thoth_app_bg.wasm", "application/wasm"), - (PKG, pkg_file) => ("../static/pkg/package.json", "/package.json", "application/json"), - (TS1, ts1_file) => ("../static/pkg/thoth_app.d.ts", "/thoth_app.d.ts", "application/typescript"), - (BULMA, bulma_file) => ("../static/css/bulma-pageloader.min.css", "/css/bulma-pageloader.min.css", "text/css; charset=utf-8"), - (CSS, css_file) => ("../static/css/thoth.css", "/css/thoth.css", "text/css; charset=utf-8"), - (LOGO, logo_file) => ("../static/img/thoth-logo.png", "/img/thoth-logo.png", "image/png"), - (BANNER, banner_file) => ("../static/img/thoth-banner.png", "/img/thoth-banner.png", "image/png"), - (COVER, cover_file) => ("../static/img/cover-placeholder.jpg", "/img/cover-placeholder.jpg", "image/jpg"), - (XML, xml_file) => ("../static/browserconfig.xml", "/browserconfig.xml", "application/xml"), - (JSON, json_file) => ("../static/manifest.json", "/manifest.json", "application/json"), - (ICON, icon_file) => ("../static/img/favicon.ico", "/favicon.ico", "image/x-icon"), - (ICON1, icon_file1) => ("../static/img/android-icon-144x144.png", "/android-icon-144x144.png", "image/png"), - (ICON2, icon_file2) => ("../static/img/android-icon-192x192.png", "/android-icon-192x192.png", "image/png"), - (ICON3, icon_file3) => ("../static/img/android-icon-36x36.png", "/android-icon-36x36.png", "image/png"), - (ICON4, icon_file4) => ("../static/img/android-icon-48x48.png", "/android-icon-48x48.png", "image/png"), - (ICON5, icon_file5) => ("../static/img/android-icon-72x72.png", "/android-icon-72x72.png", "image/png"), - (ICON6, icon_file6) => ("../static/img/android-icon-96x96.png", "/android-icon-96x96.png", "image/png"), - (ICON7, icon_file7) => ("../static/img/apple-icon-114x114.png", "/apple-icon-114x114.png", "image/png"), - (ICON8, icon_file8) => ("../static/img/apple-icon-120x120.png", "/apple-icon-120x120.png", "image/png"), - (ICON9, icon_file9) => ("../static/img/apple-icon-144x144.png", "/apple-icon-144x144.png", "image/png"), - (ICON10, icon_file10) => ("../static/img/apple-icon-152x152.png", "/apple-icon-152x152.png", "image/png"), - (ICON11, icon_file11) => ("../static/img/apple-icon-180x180.png", "/apple-icon-180x180.png", "image/png"), - (ICON12, icon_file12) => ("../static/img/apple-icon-57x57.png", "/apple-icon-57x57.png", "image/png"), - (ICON13, icon_file13) => ("../static/img/apple-icon-60x60.png", "/apple-icon-60x60.png", "image/png"), - (ICON14, icon_file14) => ("../static/img/apple-icon-72x72.png", "/apple-icon-72x72.png", "image/png"), - (ICON15, icon_file15) => ("../static/img/apple-icon-76x76.png", "/apple-icon-76x76.png", "image/png"), - (ICON16, icon_file16) => ("../static/img/apple-icon-precomposed.png", "/apple-icon-precomposed.png", "image/png"), - (ICON17, icon_file17) => ("../static/img/apple-icon.png", "/apple-icon.png", "image/png"), - (ICON18, icon_file18) => ("../static/img/favicon-16x16.png", "/favicon-16x16.png", "image/png"), - (ICON19, icon_file19) => ("../static/img/favicon-32x32.png", "/favicon-32x32.png", "image/png"), - (ICON20, icon_file20) => ("../static/img/favicon-96x96.png", "/favicon-96x96.png", "image/png"), - (ICON21, icon_file21) => ("../static/img/ms-icon-144x144.png", "/ms-icon-144x144.png", "image/png"), - (ICON22, icon_file22) => ("../static/img/ms-icon-150x150.png", "/ms-icon-150x150.png", "image/png"), - (ICON23, icon_file23) => ("../static/img/ms-icon-310x310.png", "/ms-icon-310x310.png", "image/png"), - (ICON24, icon_file24) => ("../static/img/ms-icon-70x70.png", "/ms-icon-70x70.png", "image/png"), + (JS, js_file) => ("../static/pkg/thoth_app.js", "/admin/thoth_app.js", "application/javascript"), + (WASM, wasm_file) => ("../static/pkg/thoth_app_bg.wasm", "/admin/thoth_app_bg.wasm", "application/wasm"), + (PKG, pkg_file) => ("../static/pkg/package.json", "/admin/package.json", "application/json"), + (TS1, ts1_file) => ("../static/pkg/thoth_app.d.ts", "/admin/thoth_app.d.ts", "application/typescript"), + (BULMA, bulma_file) => ("../static/css/bulma-pageloader.min.css", "/admin/css/bulma-pageloader.min.css", "text/css; charset=utf-8"), + (CSS, css_file) => ("../static/css/thoth.css", "/admin/css/thoth.css", "text/css; charset=utf-8"), + (LOGO, logo_file) => ("../static/img/thoth-logo.png", "/admin/img/thoth-logo.png", "image/png"), + (BANNER, banner_file) => ("../static/img/thoth-banner.png", "/admin/img/thoth-banner.png", "image/png"), + (COVER, cover_file) => ("../static/img/cover-placeholder.jpg", "/admin/img/cover-placeholder.jpg", "image/jpg"), + (XML, xml_file) => ("../static/browserconfig.xml", "/admin/browserconfig.xml", "application/xml"), + (JSON, json_file) => ("../static/manifest.json", "/admin/manifest.json", "application/json"), + (ICON, icon_file) => ("../static/img/favicon.ico", "/admin/favicon.ico", "image/x-icon"), + (ICON1, icon_file1) => ("../static/img/android-icon-144x144.png", "/admin/android-icon-144x144.png", "image/png"), + (ICON2, icon_file2) => ("../static/img/android-icon-192x192.png", "/admin/android-icon-192x192.png", "image/png"), + (ICON3, icon_file3) => ("../static/img/android-icon-36x36.png", "/admin/android-icon-36x36.png", "image/png"), + (ICON4, icon_file4) => ("../static/img/android-icon-48x48.png", "/admin/android-icon-48x48.png", "image/png"), + (ICON5, icon_file5) => ("../static/img/android-icon-72x72.png", "/admin/android-icon-72x72.png", "image/png"), + (ICON6, icon_file6) => ("../static/img/android-icon-96x96.png", "/admin/android-icon-96x96.png", "image/png"), + (ICON7, icon_file7) => ("../static/img/apple-icon-114x114.png", "/admin/apple-icon-114x114.png", "image/png"), + (ICON8, icon_file8) => ("../static/img/apple-icon-120x120.png", "/admin/apple-icon-120x120.png", "image/png"), + (ICON9, icon_file9) => ("../static/img/apple-icon-144x144.png", "/admin/apple-icon-144x144.png", "image/png"), + (ICON10, icon_file10) => ("../static/img/apple-icon-152x152.png", "/admin/apple-icon-152x152.png", "image/png"), + (ICON11, icon_file11) => ("../static/img/apple-icon-180x180.png", "/admin/apple-icon-180x180.png", "image/png"), + (ICON12, icon_file12) => ("../static/img/apple-icon-57x57.png", "/admin/apple-icon-57x57.png", "image/png"), + (ICON13, icon_file13) => ("../static/img/apple-icon-60x60.png", "/admin/apple-icon-60x60.png", "image/png"), + (ICON14, icon_file14) => ("../static/img/apple-icon-72x72.png", "/admin/apple-icon-72x72.png", "image/png"), + (ICON15, icon_file15) => ("../static/img/apple-icon-76x76.png", "/admin/apple-icon-76x76.png", "image/png"), + (ICON16, icon_file16) => ("../static/img/apple-icon-precomposed.png", "/admin/apple-icon-precomposed.png", "image/png"), + (ICON17, icon_file17) => ("../static/img/apple-icon.png", "/admin/apple-icon.png", "image/png"), + (ICON18, icon_file18) => ("../static/img/favicon-16x16.png", "/admin/favicon-16x16.png", "image/png"), + (ICON19, icon_file19) => ("../static/img/favicon-32x32.png", "/admin/favicon-32x32.png", "image/png"), + (ICON20, icon_file20) => ("../static/img/favicon-96x96.png", "/admin/favicon-96x96.png", "image/png"), + (ICON21, icon_file21) => ("../static/img/ms-icon-144x144.png", "/admin/ms-icon-144x144.png", "image/png"), + (ICON22, icon_file22) => ("../static/img/ms-icon-150x150.png", "/admin/ms-icon-150x150.png", "image/png"), + (ICON23, icon_file23) => ("../static/img/ms-icon-310x310.png", "/admin/ms-icon-310x310.png", "image/png"), + (ICON24, icon_file24) => ("../static/img/ms-icon-70x70.png", "/admin/ms-icon-70x70.png", "image/png"), } const INDEX_FILE: &[u8] = include_bytes!("../static/index.html"); diff --git a/thoth-app/browserconfig.xml b/thoth-app/browserconfig.xml index ab092748..28b1c0e4 100644 --- a/thoth-app/browserconfig.xml +++ b/thoth-app/browserconfig.xml @@ -1,2 +1,2 @@ -#ffdd57 +#ffdd57 diff --git a/thoth-app/css/thoth.css b/thoth-app/css/thoth.css index 4037b9ed..eb821bc1 100644 --- a/thoth-app/css/thoth.css +++ b/thoth-app/css/thoth.css @@ -94,4 +94,27 @@ text-overflow: ellipsis; white-space: nowrap; display: block; +} + +.button.primary { + color: #ffffff; + background-color: #8c3f8d; + border-width: 2px; + border-radius: .375rem; + border-color: #8c3f8d; + font-weight: bold; +} +.button.primary:hover { + background-color: #af4fb0; +} +.version { + color: #f14668; + padding-left: 1em; + padding-right: 1em; + padding-bottom: calc(.5em - 1px); + font-weight: bold; +} +.version:hover { + text-decoration: underline; + color: #f14668; } \ No newline at end of file diff --git a/thoth-app/index.html b/thoth-app/index.html index 7591d6f3..d4f9b4e4 100644 --- a/thoth-app/index.html +++ b/thoth-app/index.html @@ -7,30 +7,30 @@ Thoth - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - + diff --git a/thoth-app/main.js b/thoth-app/main.js index e0a95975..6d84ae9e 100644 --- a/thoth-app/main.js +++ b/thoth-app/main.js @@ -1,7 +1,7 @@ import init, { run_app } from "./pkg/thoth_app.js"; async function main() { - await init("/thoth_app_bg.wasm"); + await init("/admin/thoth_app_bg.wasm"); run_app(); } diff --git a/thoth-app/manifest.json b/thoth-app/manifest.json index ec91a9fc..34c79615 100644 --- a/thoth-app/manifest.json +++ b/thoth-app/manifest.json @@ -12,37 +12,37 @@ "version": "0.11.15", "icons": [ { - "src": "\/android-icon-36x36.png", + "src": "\/admin\/android-icon-36x36.png", "sizes": "36x36", "type": "image\/png", "density": "0.75" }, { - "src": "\/android-icon-48x48.png", + "src": "\/admin\/android-icon-48x48.png", "sizes": "48x48", "type": "image\/png", "density": "1.0" }, { - "src": "\/android-icon-72x72.png", + "src": "\/admin\/android-icon-72x72.png", "sizes": "72x72", "type": "image\/png", "density": "1.5" }, { - "src": "\/android-icon-96x96.png", + "src": "\/admin\/android-icon-96x96.png", "sizes": "96x96", "type": "image\/png", "density": "2.0" }, { - "src": "\/android-icon-144x144.png", + "src": "\/admin\/android-icon-144x144.png", "sizes": "144x144", "type": "image\/png", "density": "3.0" }, { - "src": "\/android-icon-192x192.png", + "src": "\/admin\/android-icon-192x192.png", "sizes": "192x192", "type": "image\/png", "density": "4.0" diff --git a/thoth-app/src/component/about.rs b/thoth-app/src/component/about.rs deleted file mode 100644 index 83e535d7..00000000 --- a/thoth-app/src/component/about.rs +++ /dev/null @@ -1,50 +0,0 @@ -use yew::html; -use yew::prelude::*; - -pub struct AboutComponent {} - -impl Component for AboutComponent { - type Message = (); - type Properties = (); - - fn create(_ctx: &Context) -> Self { - AboutComponent {} - } - - fn view(&self, _ctx: &Context) -> Html { - html! { -
-

{ "About Us" }

-
-

{ "Thoth is an open metadata management and dissemination platform. As an organisation, we are focused on:" }

-
    -
  • { "creation, curation, and dissemination of high-quality metadata records which are essential for the advancement of public knowledge;" }
  • -
  • { "promoting openness in scholarly communications such as open access, open licensing, FLOSS, open data, open metadata, and open standards and protocols;" }
  • -
  • { "embracing infrastructural and platform diversity as an inherent component of a flourishing scholarly communications landscape;" }
  • -
  • { "providing high-quality solutions and services for metadata creation, management, dissemination, archiving and preservation." }
  • -
-

{ "Thoth has been developed by Javier Arias in the context of the Community-led Open Publication Infrastructures for Monographs (COPIM) project funded by UKRI and the Arcadia Fund." }

-

{ "Thoth is incorporated as a Community Interest Company in the UK, no. 14549556." }

-

{ "Address: 40 Devonshire Road, Cambridge, United Kingdom, CB1 2BL" }

-

{ "Organisation" }

-
    -
  • { "Joe Deville (Director)" }
  • -
  • { "Rupert Gatti (Director)" }
  • -
  • { "Vincent W.J. van Gerven Oei (Director)" }
  • -
  • { "Toby Steiner (COO)" }
  • -
  • { "Javier Arias (CTO)" }
  • -
  • { "Ross Higman (Software Engineer)" }
  • -
  • { "Brendan O'Connell (Software Engineer)" }
  • -
  • { "Hannah Hillen (Metadata & Publisher Outreach Specialist)" }
  • -
-

{ "Consultants" }

-
    -
  • { "Amanda Ramalho (Thoth Representative, Latin America)" }
  • -
-

{ "Support us through the " }{ "Open Book Collective" }{ "." }

-

{ "Contact us at " }{ "info@thoth.pub" }{ "." }

-
-
- } - } -} diff --git a/thoth-app/src/component/catalogue.rs b/thoth-app/src/component/catalogue.rs deleted file mode 100644 index ae2b66f0..00000000 --- a/thoth-app/src/component/catalogue.rs +++ /dev/null @@ -1,215 +0,0 @@ -use thoth_api::model::work::WorkWithRelations; -use thoth_errors::ThothError; -use yew::html; -use yew::prelude::Component; -use yew::prelude::Context; -use yew::prelude::FocusEvent; -use yew::prelude::Html; -use yew::prelude::InputEvent; -use yewtil::fetch::Fetch; -use yewtil::fetch::FetchAction; -use yewtil::fetch::FetchState; - -use crate::component::utils::Loader; -use crate::component::utils::Reloader; -use crate::models::work::works_query::FetchActionWorks; -use crate::models::work::works_query::FetchWorks; -use crate::models::work::works_query::Variables; -use crate::models::work::works_query::WorksRequest; -use crate::models::work::works_query::WorksRequestBody; -use crate::models::work::DisplayWork; - -use super::ToElementValue; - -pub struct CatalogueComponent { - limit: i32, - offset: i32, - page_size: i32, - search_query: String, - data: Vec, - result_count: i32, - fetch_data: FetchWorks, -} - -pagination_helpers! {CatalogueComponent, PAGINATION_COUNT_WORKS, SEARCH_WORKS} - -pub enum Msg { - SetFetchState(FetchActionWorks), - GetData, - PaginateData, - #[allow(dead_code)] - Search(String), - SearchQueryChanged(String), - TriggerSearch, - NextPage, - PreviousPage, -} - -impl Component for CatalogueComponent { - type Message = Msg; - type Properties = (); - - fn create(ctx: &Context) -> Self { - let offset: i32 = Default::default(); - let page_size: i32 = 10; - let limit: i32 = page_size; - let search_query: String = Default::default(); - let result_count: i32 = Default::default(); - let data = Default::default(); - let fetch_data = Default::default(); - - ctx.link().send_message(Msg::PaginateData); - - CatalogueComponent { - limit, - offset, - page_size, - search_query, - data, - result_count, - fetch_data, - } - } - - fn update(&mut self, ctx: &Context, msg: Self::Message) -> bool { - match msg { - Msg::SetFetchState(fetch_state) => { - self.fetch_data.apply(fetch_state); - self.data = match self.fetch_data.as_ref().state() { - FetchState::Fetched(body) => body.data.works.clone(), - _ => Default::default(), - }; - self.result_count = match self.fetch_data.as_ref().state() { - FetchState::Fetched(body) => body.data.work_count, - _ => Default::default(), - }; - true - } - Msg::GetData => { - ctx.link() - .send_future(self.fetch_data.fetch(Msg::SetFetchState)); - ctx.link() - .send_message(Msg::SetFetchState(FetchAction::Fetching)); - false - } - Msg::PaginateData => { - let filter = self.search_query.clone(); - let body = WorksRequestBody { - variables: Variables { - limit: Some(self.limit), - offset: Some(self.offset), - filter: Some(filter), - // Sorting option is not required on Catalogue page - order: None, - // Catalogue is public so results should never be filtered by logged-in user - publishers: None, - }, - ..Default::default() - }; - let request = WorksRequest { body }; - self.fetch_data = Fetch::new(request); - ctx.link().send_message(Msg::GetData); - false - } - Msg::Search(_) => { - // needed because of macro, but unused here - false - } - Msg::SearchQueryChanged(term) => { - self.search_query = term; - false - } - Msg::TriggerSearch => { - self.limit = self.page_size; - self.offset = 0; - ctx.link().send_message(Msg::PaginateData); - false - } - Msg::NextPage => { - if self.limit < self.result_count && !self.is_next_disabled() { - self.offset += self.page_size; - ctx.link().send_message(Msg::PaginateData); - } - false - } - Msg::PreviousPage => { - if self.offset > 0 && !self.is_previous_disabled() { - self.offset -= self.page_size; - ctx.link().send_message(Msg::PaginateData); - } - false - } - } - } - - fn view(&self, ctx: &Context) -> Html { - html! { -
-

{ "Catalogue" }

- - - { - match self.fetch_data.as_ref().state() { - FetchState::NotFetching(_) => { - html! {} - } - FetchState::Fetching(_) => html! {}, - FetchState::Fetched(_body) => html! { - { for self.data.iter().map(|w| w.as_catalogue_box()) } - }, - FetchState::Failed(_, err) => html! { - { ThothError::from(err).to_string() } - }, - } - } -
- } - } -} diff --git a/thoth-app/src/component/hero.rs b/thoth-app/src/component/hero.rs deleted file mode 100644 index 7e5861a1..00000000 --- a/thoth-app/src/component/hero.rs +++ /dev/null @@ -1,94 +0,0 @@ -use yew::function_component; -use yew::html; - -use crate::{THOTH_EXPORT_API, THOTH_GRAPHQL_API}; - -#[function_component(HeroComponent)] -pub fn hero_component() -> VNode { - let graphiql = format!("{THOTH_GRAPHQL_API}/graphiql"); - html! { -
- -
- } -} diff --git a/thoth-app/src/component/mod.rs b/thoth-app/src/component/mod.rs index d50c38c8..dd2b77a0 100644 --- a/thoth-app/src/component/mod.rs +++ b/thoth-app/src/component/mod.rs @@ -449,11 +449,9 @@ impl ToElementValue for Option { } } -pub mod about; pub mod admin; pub mod affiliations_form; pub mod books; -pub mod catalogue; pub mod chapters; pub mod contributions_form; pub mod contributor; @@ -461,7 +459,6 @@ pub mod contributors; pub mod dashboard; pub mod delete_dialogue; pub mod fundings_form; -pub mod hero; pub mod imprint; pub mod imprints; pub mod institution; diff --git a/thoth-app/src/component/navbar.rs b/thoth-app/src/component/navbar.rs index be63d0f2..6210ecda 100644 --- a/thoth-app/src/component/navbar.rs +++ b/thoth-app/src/component/navbar.rs @@ -4,9 +4,7 @@ use yew::prelude::*; use yew::virtual_dom::VNode; use yew_router::prelude::*; -use crate::route::AdminRoute; use crate::route::AppRoute; -use crate::{THOTH_EXPORT_API, THOTH_GRAPHQL_API}; pub struct NavbarComponent {} @@ -42,12 +40,11 @@ impl Component for NavbarComponent { e.prevent_default(); Msg::Logout }); - let graphiql = format!("{THOTH_GRAPHQL_API}/graphiql"); html! {