Skip to content

Commit

Permalink
Added manifest.json in backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Aug 30, 2024
1 parent 901b0ac commit 6c6a492
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 3,483 deletions.
50 changes: 50 additions & 0 deletions src/controllers/manifest_controller.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use actix_web::{get, HttpResponse};
use crate::constants::inner_constants::ENVIRONMENT_SERVICE;
use crate::utils::error::CustomError;

#[derive(Serialize)]
pub struct Icon {
pub src: String,
pub sizes: String,
pub r#type: String
}


#[derive(Serialize)]
pub struct Manifest {
pub name: String,
pub short_name: String,
pub start_url: String,
pub icons: Vec<Icon>,
pub theme_color: String,
pub background_color: String,
pub display: String,
pub orientation: String
}



#[get("manifest.json")]
pub async fn get_manifest() -> Result<HttpResponse, CustomError> {
let env_service = ENVIRONMENT_SERVICE.get().unwrap();
let mut icons = Vec::new();
let icon = Icon{
src: env_service.server_url.to_string()+"ui/logo.png",
sizes: "512x512".to_string(),
r#type: "image/png".to_string()
};
icons.push(icon);


let manifest = Manifest{
name: "PodFetch".to_string(),
short_name: "PodFetch".to_string(),
start_url: env_service.server_url.to_string(),
icons,
orientation: "landscape".to_string(),
theme_color: "#ffffff".to_string(),
display: "fullscreen".to_string(),
background_color: "#ffffff".to_string()
};
Ok(HttpResponse::Ok().json(manifest))
}
1 change: 1 addition & 0 deletions src/controllers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pub mod web_socket;
pub mod websocket_controller;
pub mod tags_controller;
pub mod server;
pub mod manifest_controller;
22 changes: 22 additions & 0 deletions src/dbconfig/schemas/sqlite/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ diesel::table! {
}
}

diesel::table! {
tags (id) {
id -> Text,
name -> Text,
username -> Text,
description -> Nullable<Text>,
created_at -> Timestamp,
color -> Text,
}
}

diesel::table! {
tags_podcasts (tag_id, podcast_id) {
tag_id -> Text,
podcast_id -> Integer,
}
}

diesel::table! {
users (id) {
id -> Integer,
Expand All @@ -194,6 +212,8 @@ diesel::joinable!(favorites -> podcasts (podcast_id));
diesel::joinable!(playlist_items -> playlists (playlist_id));
diesel::joinable!(playlist_items -> podcast_episodes (episode));
diesel::joinable!(podcast_episodes -> podcasts (podcast_id));
diesel::joinable!(tags_podcasts -> podcasts (podcast_id));
diesel::joinable!(tags_podcasts -> tags (tag_id));

diesel::allow_tables_to_appear_in_same_query!(
devices,
Expand All @@ -210,5 +230,7 @@ diesel::allow_tables_to_appear_in_same_query!(
sessions,
settings,
subscriptions,
tags,
tags_podcasts,
users,
);
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use crate::controllers::websocket_controller::{
};
use crate::dbconfig::DBType;
pub use controllers::controller_utils::*;
use crate::controllers::manifest_controller::get_manifest;
use crate::controllers::server::ChatServer;
use crate::controllers::tags_controller::{add_podcast_to_tag, delete_tag, get_tags, insert_tag, update_tag};

Expand Down Expand Up @@ -390,6 +391,7 @@ pub fn get_global_scope() -> Scope {
.service(service)
.service(start_connection)
.service(get_rss_feed)
.service(get_manifest)
.service(get_rss_feed_for_podcast)
}

Expand Down
1 change: 0 additions & 1 deletion src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub mod settings;
pub mod subscription;
pub mod subscription_changes_from_client;
pub mod user;
pub mod web_socket_message;
pub mod tag;
pub mod tags_podcast;
pub mod color;
Expand Down
1 change: 1 addition & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Podfetch</title>
<link rel="manifest" href="/manifest.json" />
</head>
<body>
<div id="root"></div>
Expand Down
5 changes: 1 addition & 4 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"build-github": "tsc && vite build --outDir ../static",
"generate-pwa-assets": "pwa-assets-generator"
"build-github": "tsc && vite build --outDir ../static"
},
"dependencies": {
"@fontsource-variable/inter": "^5.0.20",
Expand Down Expand Up @@ -52,7 +51,6 @@
"@types/react": "^18.3.4",
"@types/react-dom": "^18.2.22",
"@types/sanitize-html": "^2.11.0",
"@vite-pwa/assets-generator": "^0.2.4",
"@vitejs/plugin-react-swc": "^3.7.0",
"autoprefixer": "^10.4.20",
"jsdom": "^24.1.1",
Expand All @@ -61,7 +59,6 @@
"tailwindcss": "^3.4.9",
"typescript": "^5.5.4",
"vite": "^5.4.2",
"vite-plugin-pwa": "^0.20.1",
"vitest": "^2.0.5"
}
}
Loading

0 comments on commit 6c6a492

Please sign in to comment.