mirror of
https://gitlab.com/Anson-Projects/projects.git
synced 2025-09-19 03:52:37 +00:00
Compare commits
21 Commits
cf5021e682
...
ghost-cont
Author | SHA1 | Date | |
---|---|---|---|
85adfdf067 | |||
c9e0264208 | |||
d3966eaf53 | |||
21ad5cb862 | |||
9e2596c070 | |||
f93746e2c0 | |||
ae1be54f8f | |||
e479c96e44 | |||
890775b2bc | |||
788052233a | |||
1a4773b3ef | |||
84f4e48386 | |||
52229040c6 | |||
b70c57e23e | |||
f6532e4fb6 | |||
0675f1f1b7 | |||
b5a4b33b56 | |||
9fc6a9bae1 | |||
05474b986d | |||
cdb96a50b7 | |||
e233a96f55 |
@@ -2,15 +2,11 @@ publish:
|
|||||||
stage: deploy
|
stage: deploy
|
||||||
image: rust:latest
|
image: rust:latest
|
||||||
script:
|
script:
|
||||||
- echo "Listing project root directory:"
|
|
||||||
- ls -la
|
|
||||||
- echo "Listing public directory:"
|
|
||||||
- ls -la public/ || echo "public directory not found"
|
|
||||||
- echo "Looking for index.xml:"
|
|
||||||
- find . -name "index.xml" -type f || echo "No index.xml files found"
|
|
||||||
- cd ./ghost-upload
|
- cd ./ghost-upload
|
||||||
- cargo run
|
- cargo run
|
||||||
needs:
|
needs:
|
||||||
- pages
|
- job: pages
|
||||||
|
optional: true
|
||||||
rules:
|
rules:
|
||||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||||
|
- if: "$CI_COMMIT_BRANCH == 'ghost-content-extraction'" # Allow testing on this branch
|
||||||
|
@@ -227,39 +227,48 @@ async fn get_existing_post_id(slug: &str, token: &str) -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_feed(path: &str) -> Vec<Entry> {
|
async fn fetch_feed(url: &str) -> Vec<Entry> {
|
||||||
// Debug: Print current directory and list files
|
println!("Fetching RSS feed from: {}", url);
|
||||||
if let Ok(current_dir) = std::env::current_dir() {
|
|
||||||
eprintln!("Current directory: {:?}", current_dir);
|
let response = reqwest::get(url).await;
|
||||||
|
let response = match response {
|
||||||
|
Ok(resp) => resp,
|
||||||
|
Err(e) => {
|
||||||
|
println!("Failed to fetch RSS feed: {}", e);
|
||||||
|
return vec![];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
println!("RSS feed request failed with status: {}", response.status());
|
||||||
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug: List files in parent directory
|
let content = match response.text().await {
|
||||||
if let Ok(entries) = std::fs::read_dir("..") {
|
Ok(text) => text,
|
||||||
eprintln!("Files in parent directory:");
|
Err(e) => {
|
||||||
for entry in entries {
|
println!("Failed to read RSS feed content: {}", e);
|
||||||
if let Ok(entry) = entry {
|
return vec![];
|
||||||
eprintln!(" {:?}", entry.path());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if content.trim().is_empty() {
|
||||||
|
println!("RSS feed content is empty");
|
||||||
|
return vec![];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug: Check if public directory exists
|
println!("RSS feed content preview: {}", &content[..content.len().min(200)]);
|
||||||
if let Ok(entries) = std::fs::read_dir("../public") {
|
|
||||||
eprintln!("Files in ../public:");
|
|
||||||
for entry in entries {
|
|
||||||
if let Ok(entry) = entry {
|
|
||||||
eprintln!(" {:?}", entry.path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
eprintln!("../public directory does not exist or cannot be read");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read from local file instead of HTTP request
|
let feed = match parser::parse(content.as_bytes()) {
|
||||||
let content = std::fs::read_to_string(path).expect("Failed to read RSS feed file");
|
Ok(f) => f,
|
||||||
|
Err(e) => {
|
||||||
let feed = parser::parse(content.as_bytes()).expect("Failed to parse RSS feed");
|
println!("Failed to parse RSS feed: {:?}", e);
|
||||||
|
println!("Feed content starts with: {}", &content[..content.len().min(500)]);
|
||||||
|
return vec![];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Successfully parsed RSS feed with {} entries", feed.entries.len());
|
||||||
feed.entries
|
feed.entries
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +333,7 @@ async fn main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
let feed = "../public/index.xml";
|
let feed = "https://projects.ansonbiggs.com/index.xml";
|
||||||
|
|
||||||
// Split the key into ID and SECRET
|
// Split the key into ID and SECRET
|
||||||
let (id, secret) = ghost_admin_api_key
|
let (id, secret) = ghost_admin_api_key
|
||||||
@@ -357,6 +366,13 @@ async fn main() {
|
|||||||
// Prepare the post data
|
// Prepare the post data
|
||||||
let entries = fetch_feed(feed).await;
|
let entries = fetch_feed(feed).await;
|
||||||
|
|
||||||
|
if entries.is_empty() {
|
||||||
|
println!("No entries found in RSS feed or feed parsing failed. Exiting.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Processing {} entries from RSS feed", entries.len());
|
||||||
|
|
||||||
let post_exists_futures = entries.into_iter().map(|entry| {
|
let post_exists_futures = entries.into_iter().map(|entry| {
|
||||||
let entry_clone = entry.clone();
|
let entry_clone = entry.clone();
|
||||||
let token_clone = token.clone();
|
let token_clone = token.clone();
|
||||||
|
Reference in New Issue
Block a user