Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website/scripts/docsmg: final version #11501

Merged
merged 46 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
01609cb
add docsmg tool
ObamaTheLlama114 Jul 26, 2024
3eb2f0f
moved to the correct scripts directory
ObamaTheLlama114 Jul 26, 2024
e5b7d51
removed test files
ObamaTheLlama114 Jul 26, 2024
47ec315
added install script and readme draft to docsmg
ObamaTheLlama114 Jul 26, 2024
c6bffd9
fix merge conflicts
ObamaTheLlama114 Jul 26, 2024
70065d6
fix install script
ObamaTheLlama114 Jul 28, 2024
a511920
fixed issues
ObamaTheLlama114 Jul 29, 2024
ab68918
Revert "fixed issues"
ObamaTheLlama114 Jul 29, 2024
e693c03
Revert "Revert "fixed issues""
ObamaTheLlama114 Jul 29, 2024
82074b7
Merge branch 'main' of https://github.com/ObamaTheLlama114/authentik …
ObamaTheLlama114 Jul 29, 2024
3cc6005
added dotenv and updated readme
ObamaTheLlama114 Jul 29, 2024
f8abb86
fixed install script
ObamaTheLlama114 Jul 29, 2024
a03dbcb
update readme to ensure that new installers of rust have envs loaded
ObamaTheLlama114 Jul 29, 2024
c0c91b8
resolved merge conflicts
ObamaTheLlama114 Jul 29, 2024
1df6e38
changed docsmg from using .env to docsmg.env
ObamaTheLlama114 Jul 29, 2024
3906f04
Merge branch 'goauthentik:main' into docsmg
ObamaTheLlama114 Jul 29, 2024
72e62b1
fixed docsmg to fix internal links in file
ObamaTheLlama114 Aug 26, 2024
fa75cc1
Merge branch 'docsmg' of https://github.com/ObamaTheLlama114/authenti…
ObamaTheLlama114 Aug 26, 2024
a9566b4
Merge branch 'main' into docsmg
tanberry Aug 26, 2024
4e52704
fixed docsmg migrate not making directories to file
ObamaTheLlama114 Aug 26, 2024
5f282d2
Merge branch 'docsmg' of https://github.com/ObamaTheLlama114/authenti…
ObamaTheLlama114 Aug 26, 2024
5242918
fixed docsmg migrate trying to read pngs to string
ObamaTheLlama114 Aug 26, 2024
325c303
did stuff
ObamaTheLlama114 Aug 26, 2024
138eb0d
fix links
ObamaTheLlama114 Aug 30, 2024
b6ed2e9
fix links 2
ObamaTheLlama114 Sep 1, 2024
cf8a78a
fix links 3
ObamaTheLlama114 Sep 1, 2024
ba54fb1
fix links
ObamaTheLlama114 Sep 1, 2024
b3b2849
fix links
ObamaTheLlama114 Sep 2, 2024
c68d490
fix links
ObamaTheLlama114 Sep 2, 2024
b2c93c9
fix links
ObamaTheLlama114 Sep 2, 2024
dd0ff3e
fix links
ObamaTheLlama114 Sep 2, 2024
54a05d1
fixed docsmg migrate replacing links
ObamaTheLlama114 Sep 2, 2024
2f5799d
fixed docsmg migrate replacing links
ObamaTheLlama114 Sep 2, 2024
7c0aab3
fixed docsmg migrate replacing links
ObamaTheLlama114 Sep 2, 2024
f22484f
fixed docsmg migrate replacing links
ObamaTheLlama114 Sep 2, 2024
57f0ac2
fixed links
ObamaTheLlama114 Sep 2, 2024
bb964c9
update docsmg fixing links
ObamaTheLlama114 Sep 3, 2024
bab5482
update docsmg fixing links
ObamaTheLlama114 Sep 3, 2024
22404aa
update docsmg fixing links
ObamaTheLlama114 Sep 3, 2024
7c7b87e
update docsmg removing empty directories
ObamaTheLlama114 Sep 4, 2024
2cc4f77
Merge branch 'goauthentik:main' into rework_docsmg
ObamaTheLlama114 Sep 25, 2024
64350c8
Merge branch 'goauthentik:main' into rework_docsmg
ObamaTheLlama114 Sep 26, 2024
2e21a5b
remove changed docs
ObamaTheLlama114 Sep 26, 2024
d09f80f
Revert "remove changed docs"
ObamaTheLlama114 Sep 26, 2024
8b70cf3
remove changed docs
ObamaTheLlama114 Sep 26, 2024
02dbd9a
fixed readme
ObamaTheLlama114 Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions website/scripts/docsmg/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/scripts/docsmg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ anyhow = "1.0.86"
clap = { version = "4.5.9", features = ["derive", "env"] }
colored = "2.1.0"
dotenv = "0.15.0"
regex = "1.10.6"
tokio = "1.38.0"
6 changes: 6 additions & 0 deletions website/scripts/docsmg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Use this migration tool to:

## Steps to use

1. Generate a migratefile with `docsmg generate >> migratefile`
2. Find the files you want to move in `migratefile` and insert the path you want to move them to after the arrow; ex `path/to/move/from/file.md -> path/to/move/to/file.md` Note: make sure to put spaces on either side of the arrow or that line won't be recognized
3. Once you have entered all the paths you want to move, migrate the files with `docsmg migrate`
4. To revert the migration, use `docsmg unmigrate`; Note: DO NOT edit the migrate file in between steps 3 and 4
5. Repeat steps 2-4 until you are satisfied with the result

### Create the mapping file (`migratefile`)

1. Navigate to the `authentik/website` dir.
Expand Down
24 changes: 24 additions & 0 deletions website/scripts/docsmg/src/hackyfixes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::{ffi::OsStr, fs::{read_to_string, write}, path::PathBuf};

use crate::recurse_directory;

pub fn add_extra_dot_dot_to_expression_mdx(migrate_path: PathBuf) {
let binding = recurse_directory(migrate_path);
let files = binding.iter().filter(|x| if let Some(i) = x.file_name() {
if Some("expression.mdx") == i.to_str() || Some("expressions.md") == i.to_str() {
true
} else {
false
}
} else {
false
});

for file in files {
let content = match read_to_string(file) {
Ok(i) => i,
_ => continue,
};
let _ = write(file, content.replace("../expressions", "../../expressions"));
}
}
34 changes: 34 additions & 0 deletions website/scripts/docsmg/src/links.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::{fs::read_to_string, path::PathBuf};

use regex::{Captures, Regex};

use crate::recurse_directory;

pub fn shorten_all_external_links(migrate_path: PathBuf) {
let files = recurse_directory(migrate_path.clone());
for file in files {
let file = migrate_path.join(file);
let absolute_file = file.clone().canonicalize().unwrap();
let contents = if let Ok(x) = read_to_string(file) {
x
} else {
continue;
};
let re = Regex::new(r"\[(?<name>.*)\]\((?<link>.*)\)").unwrap();
let captures: Vec<Captures> = re.captures_iter(&contents).collect();
for capture in captures {
let link = &capture["link"];
let link = PathBuf::from(link);
let absolute_link = absolute_file
.clone()
.parent()
.unwrap()
.join(link)
.canonicalize()
.unwrap();
shorten_link_relative_to(absolute_link.clone(), absolute_file.clone());
}
}
}

fn shorten_link_relative_to(link_to_shorten: PathBuf, relative_to: PathBuf) {}
2 changes: 2 additions & 0 deletions website/scripts/docsmg/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use std::{fs, path::PathBuf};
use clap::{Parser, Subcommand};

mod generate;
mod links;
mod migrate;
mod migratefile;
mod r#move;
mod hackyfixes;

#[derive(Parser)]
struct Cli {
Expand Down
Loading
Loading