pinakes-server: add notes API endpoints for backlinks
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6345960fca2afb4e080939b5fd73ea346a6a6964
This commit is contained in:
parent
27be136e01
commit
2c69691060
2 changed files with 19 additions and 11 deletions
|
|
@ -233,10 +233,7 @@ pub fn create_router_with_tls(
|
|||
get(routes::shares::get_notifications),
|
||||
)
|
||||
// Markdown notes/links (read)
|
||||
.route(
|
||||
"/media/{id}/backlinks",
|
||||
get(routes::notes::get_backlinks),
|
||||
)
|
||||
.route("/media/{id}/backlinks", get(routes::notes::get_backlinks))
|
||||
.route(
|
||||
"/media/{id}/outgoing-links",
|
||||
get(routes::notes::get_outgoing_links),
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
//! - Link reindexing
|
||||
|
||||
use axum::{
|
||||
Json, Router,
|
||||
extract::{Path, Query, State},
|
||||
routing::{get, post},
|
||||
Json, Router,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
|
@ -144,8 +144,16 @@ impl From<GraphData> for GraphResponse {
|
|||
let node_count = data.nodes.len();
|
||||
let edge_count = data.edges.len();
|
||||
Self {
|
||||
nodes: data.nodes.into_iter().map(GraphNodeResponse::from).collect(),
|
||||
edges: data.edges.into_iter().map(GraphEdgeResponse::from).collect(),
|
||||
nodes: data
|
||||
.nodes
|
||||
.into_iter()
|
||||
.map(GraphNodeResponse::from)
|
||||
.collect(),
|
||||
edges: data
|
||||
.edges
|
||||
.into_iter()
|
||||
.map(GraphEdgeResponse::from)
|
||||
.collect(),
|
||||
node_count,
|
||||
edge_count,
|
||||
}
|
||||
|
|
@ -219,7 +227,10 @@ pub async fn get_outgoing_links(
|
|||
let items: Vec<OutgoingLinkItem> = links.into_iter().map(OutgoingLinkItem::from).collect();
|
||||
let count = items.len();
|
||||
|
||||
Ok(Json(OutgoingLinksResponse { links: items, count }))
|
||||
Ok(Json(OutgoingLinksResponse {
|
||||
links: items,
|
||||
count,
|
||||
}))
|
||||
}
|
||||
|
||||
/// Get graph data for visualization.
|
||||
|
|
@ -262,9 +273,9 @@ pub async fn reindex_links(
|
|||
}
|
||||
|
||||
// Read the file content
|
||||
let content = tokio::fs::read_to_string(&media.path).await.map_err(|e| {
|
||||
ApiError::internal(format!("Failed to read file: {}", e))
|
||||
})?;
|
||||
let content = tokio::fs::read_to_string(&media.path)
|
||||
.await
|
||||
.map_err(|e| ApiError::internal(format!("Failed to read file: {}", e)))?;
|
||||
|
||||
// Extract links
|
||||
let links = pinakes_core::links::extract_links(media_id, &content);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue