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
|
||||
image: rust:latest
|
||||
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
|
||||
- cargo run
|
||||
needs:
|
||||
- pages
|
||||
- job: pages
|
||||
optional: true
|
||||
rules:
|
||||
- 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> {
|
||||
// Debug: Print current directory and list files
|
||||
if let Ok(current_dir) = std::env::current_dir() {
|
||||
eprintln!("Current directory: {:?}", current_dir);
|
||||
}
|
||||
async fn fetch_feed(url: &str) -> Vec<Entry> {
|
||||
println!("Fetching RSS feed from: {}", url);
|
||||
|
||||
// Debug: List files in parent directory
|
||||
if let Ok(entries) = std::fs::read_dir("..") {
|
||||
eprintln!("Files in parent directory:");
|
||||
for entry in entries {
|
||||
if let Ok(entry) = entry {
|
||||
eprintln!(" {:?}", entry.path());
|
||||
}
|
||||
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: Check if public directory exists
|
||||
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());
|
||||
}
|
||||
let content = match response.text().await {
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
println!("Failed to read RSS feed content: {}", e);
|
||||
return vec![];
|
||||
}
|
||||
} else {
|
||||
eprintln!("../public directory does not exist or cannot be read");
|
||||
};
|
||||
|
||||
if content.trim().is_empty() {
|
||||
println!("RSS feed content is empty");
|
||||
return vec![];
|
||||
}
|
||||
|
||||
// Read from local file instead of HTTP request
|
||||
let content = std::fs::read_to_string(path).expect("Failed to read RSS feed file");
|
||||
println!("RSS feed content preview: {}", &content[..content.len().min(200)]);
|
||||
|
||||
let feed = parser::parse(content.as_bytes()).expect("Failed to parse RSS feed");
|
||||
let feed = match parser::parse(content.as_bytes()) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
let (id, secret) = ghost_admin_api_key
|
||||
@@ -357,6 +366,13 @@ async fn main() {
|
||||
// Prepare the post data
|
||||
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 entry_clone = entry.clone();
|
||||
let token_clone = token.clone();
|
||||
|
Reference in New Issue
Block a user