-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a47fce8
commit 17ba543
Showing
18 changed files
with
244 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,17 +23,17 @@ jobs: | |
run: pip install -r requirements.txt # If you have any dependencies | ||
|
||
- name: Generate Post HTML | ||
run: python scripts/generate_post.py ${{ github.event.issue.number }} "${{ github.event.issue.title }}" "${{ github.event.issue.user.login }}" "${{ github.event.issue.body }}" | ||
run: python scripts/generate_post ${{ github.event.issue.number }} "${{ github.event.issue.title }}" "${{ github.event.issue.user.login }}" "${{ github.event.issue.body }}" "${{ format(github.event.issue.created_at, 'YYYY-MM-DD HH:mm:ss') }}" | ||
|
||
- name: Add new post to recents page | ||
run: python scripts/add_to_recent.py ${{ github.event.issue.number }} "${{ github.event.issue.title }}" "${{ github.event.issue.user.login }}" "${{ github.event.issue.body }}" | ||
run: python scripts/add_to_recent.py ${{ github.event.issue.number }} "${{ github.event.issue.title }}" "${{ github.event.issue.user.login }}" "${{ github.event.issue.body }}" "${{ format(github.event.issue.created_at, 'YYYY-MM-DD HH:mm:ss') }}" | ||
|
||
- name: Commit and Push Changes | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m "Generate HTML for issue #${{ github.event.issue.number }}" | ||
git commit -m "Generate Post page for issue #${{ github.event.issue.number }}" | ||
git push | ||
comment: | ||
|
@@ -47,5 +47,5 @@ jobs: | |
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "Your post going to be available after a few seconds in https://nimafanniasl.github.io/GithubForum/posts/${{ github.event.issue.number }}.html" | ||
body: "Your post is going to be available after a few seconds in https://nimafanniasl.github.io/GithubForum/posts/${{ github.event.issue.number }}.html" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/scripts_rust/target | ||
/scripts_rust/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
## A (NOT) Fully functioning Forum made just with Free Github hosting and Github pages. (WIP) | ||
|
||
### TODO: | ||
- [ ] Be able Remove Comments | ||
- [ ] Be able to Remove Comments | ||
- [ ] Complete home page | ||
- [ ] Make the footer always stick to the down of the screen | ||
- [ ] Make the header and footer dynamic and load from a javascript file | ||
- [ ] Add reactions to posts | ||
- [ ] access for everyone to assign posts to labels | ||
- [ ] Toggle for switching between light and dark mode | ||
- [ ] Toggle for switching between light and dark mode | ||
- [ ] Complete the categories page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "scripts_rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["nimafanniasl"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
reqwest = { version = "0.11.24", features = ["default", "json", "blocking"] } | ||
serde_json = "1.0.113" | ||
|
||
|
||
[[bin]] | ||
name = "generate_post" | ||
path = "src/generate_post.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// import sys | ||
// from datetime import datetime | ||
// from bs4 import BeautifulSoup | ||
|
||
// def add_section_to_html(html_file, new_section_html): | ||
// with open(html_file, 'r') as file: | ||
// soup = BeautifulSoup(file, 'html.parser') | ||
|
||
// main_tag = soup.find('main') | ||
|
||
// if main_tag: | ||
// # Create a new section and add it to the top of the main element | ||
// new_section = BeautifulSoup(new_section_html, 'html.parser') | ||
// main_tag.insert(0, new_section) | ||
|
||
// with open(html_file, 'w') as file: | ||
// file.write(str(soup)) | ||
|
||
// def remove_oldest_section(html_file): | ||
// with open(html_file, 'r') as file: | ||
// soup = BeautifulSoup(file, 'html.parser') | ||
|
||
// main_tag = soup.find('main') | ||
// if main_tag: | ||
// sections = main_tag.find_all('section') | ||
|
||
// if len(sections) > 10: | ||
// # Remove the oldest section (last one in the list) | ||
// sections[-1].decompose() | ||
|
||
// with open(html_file, 'w') as file: | ||
// file.write(str(soup)) | ||
|
||
// def remove_duplicate_posts(html_file, issue_number): | ||
// with open(html_file, 'r') as file: | ||
// soup = BeautifulSoup(file, 'html.parser') | ||
|
||
// main_tag = soup.find('main') | ||
// if main_tag: | ||
// sections = main_tag.find_all('section') | ||
|
||
// for section in sections: | ||
// if section.get('id') == str(issue_number): | ||
// section.decompose() | ||
|
||
// with open(html_file, 'w') as file: | ||
// file.write(str(soup)) | ||
|
||
// if __name__ == "__main__": | ||
// issue_number = sys.argv[1] | ||
// post_title = sys.argv[2] | ||
// post_author = sys.argv[3] | ||
// post_content = sys.argv[4] | ||
|
||
// post_content = "".join(post_content[:70]) + "..." | ||
// print(post_content) | ||
|
||
// recent_html = "recent.html" | ||
|
||
// with open("templates/section.html", "r") as section_template: | ||
// new_section_html = section_template.read() | ||
|
||
// new_section_html = new_section_html.replace("{POST-TITLE}", post_title) | ||
// new_section_html = new_section_html.replace("{POST-AUTHOR}", post_author) | ||
// new_section_html = new_section_html.replace("{POST-DATE}", datetime.now().strftime("%Y-%m-%d")) | ||
// new_section_html = new_section_html.replace("{POST-NUMBER}", issue_number) | ||
// new_section_html = new_section_html.replace("{MINIFIED-POST-CONTENT}", post_content) | ||
// new_section_html = new_section_html.replace("{POST-PAGE-LINK}", f"https://nimafanniasl.github.io/GithubForum/posts/{issue_number}.html") | ||
|
||
// # Remove suplicate post | ||
// remove_duplicate_posts(recent_html, issue_number) | ||
|
||
// # Add the new section to the HTML file | ||
// add_section_to_html(recent_html, new_section_html) | ||
|
||
// # Remove the oldest section if there are more than 10 sections | ||
// remove_oldest_section(recent_html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::env; | ||
// use std::fmt::format; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
|
||
fn main() { | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
let issue_number = &args[1]; | ||
let post_title = &args[2]; | ||
let post_author = &args[3]; | ||
let post_content = &args[4]; | ||
let post_created_date = &args[5]; | ||
|
||
let template_file_path = "../templates/posttemplate.html"; | ||
|
||
let template_file = fs::read_to_string(template_file_path) | ||
.expect("Should have been able to read the file"); | ||
|
||
let output_directory = "../posts"; | ||
|
||
|
||
let mut html_content = String::from(template_file); | ||
|
||
html_content = html_content.replace("{POST-TITLE}", &post_title); | ||
html_content = html_content.replace("{POST-AUTHOR}", &post_author); | ||
html_content = html_content.replace("{POST-DATE}", &post_created_date); | ||
html_content = html_content.replace("{POST-NUMBER}", &issue_number); | ||
html_content = html_content.replace("{POST-CONTENT}", &post_content); | ||
|
||
match fs::create_dir(&output_directory) { | ||
Ok(()) => println!("Dir created"), | ||
_ => println!("Dir already exists") | ||
} | ||
|
||
// Change the file creation and write operations as follows | ||
let mut file = File::create(format!("{}/{}.html", output_directory, issue_number)) | ||
.expect("Failed to create file"); | ||
|
||
file.write_all(html_content.as_bytes()) | ||
.expect("Failed to write to file"); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// import sys | ||
// import os | ||
// from bs4 import BeautifulSoup | ||
// from datetime import datetime | ||
// from includes import * | ||
|
||
// mode = sys.argv[1] | ||
// issue_number = sys.argv[2] | ||
// post_author = sys.argv[3] | ||
// post_content = convert_md_to_html(sys.argv[4]) | ||
|
||
|
||
// if mode.lower() == "add": | ||
// pfp_url = get_pfp(post_author) | ||
|
||
// posts_dir = "posts" | ||
// issue_html = os.path.join(posts_dir, f"{issue_number}.html") | ||
|
||
// with open("templates/comment.html", "r") as isuue_comment: | ||
// isuue_comment_template = isuue_comment.read() | ||
|
||
// isuue_comment_template = isuue_comment_template.replace("{POST-CONTENT}", post_content) | ||
// isuue_comment_template = isuue_comment_template.replace("{POST-AUTHOR}", post_author) | ||
// isuue_comment_template = isuue_comment_template.replace("{POST-DATE}", | ||
// datetime.now().strftime("%Y-%m-%d")) | ||
// isuue_comment_template = isuue_comment_template.replace("{PFP-URL}", pfp_url) | ||
|
||
// # Read existing issue_html content and parse it with BeautifulSoup | ||
// with open(issue_html, "r", encoding="utf-8") as html_file: | ||
// soup = BeautifulSoup(html_file, "html.parser") | ||
|
||
// # Find the <main> section | ||
// main_section = soup.find("main") | ||
|
||
// # Append the modified isuue_comment_template to <main> | ||
// main_section.append(BeautifulSoup(isuue_comment_template, "html.parser")) | ||
|
||
// # Save the updated HTML back to issue_html | ||
// with open(issue_html, "w", encoding="utf-8") as html_file: | ||
// html_file.write(str(soup)) |
Oops, something went wrong.