...
This commit is contained in:
@@ -47,7 +47,6 @@ pub fn cmd_atlas(mut cmdroot Command) Command {
|
||||
description: 'Path where collection.json... will be saved too.'
|
||||
})
|
||||
|
||||
|
||||
cmd_run.add_flag(Flag{
|
||||
flag: .string
|
||||
required: false
|
||||
@@ -145,8 +144,8 @@ fn cmd_atlas_execute(cmd Command) ! {
|
||||
)!
|
||||
|
||||
// Create or get atlas instance
|
||||
mut a := if atlas.atlas_exists(name) {
|
||||
atlas.atlas_get(name)!
|
||||
mut a := if atlas.exists(name) {
|
||||
atlas.get(name)!
|
||||
} else {
|
||||
atlas.new(name: name)!
|
||||
}
|
||||
@@ -160,7 +159,7 @@ fn cmd_atlas_execute(cmd Command) ! {
|
||||
// Execute operations
|
||||
if scan {
|
||||
console.print_header('Scanning collections...')
|
||||
a.scan(path: atlas_path.path, meta_path: path_meta)!
|
||||
a.scan(path: atlas_path.path)!
|
||||
console.print_green('✓ Scan complete: ${a.collections.len} collection(s) found')
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ pub mut:
|
||||
ignore []string // list of directory names to ignore
|
||||
}
|
||||
|
||||
fn (mut a Atlas) scan(args ScanArgs) ! {
|
||||
pub fn (mut a Atlas) scan(args ScanArgs) ! {
|
||||
mut path := pathlib.get_dir(path: args.path)!
|
||||
mut ignore := args.ignore.clone()
|
||||
ignore = ignore.map(it.to_lower())
|
||||
|
||||
@@ -302,6 +302,11 @@ fn (mut c Collection) init_git_info() ! {
|
||||
mut gs := gittools.new()!
|
||||
mut p := c.path()!
|
||||
mut location := gs.gitlocation_from_path(p.path)!
|
||||
|
||||
r := os.execute_opt('cd ${p.path} && git branch --show-current')!
|
||||
|
||||
location.branch_or_tag = r.output.trim_space()
|
||||
|
||||
c.git_url = location.web_url()!
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn (mut c Collection) export(args CollectionExportArgs) ! {
|
||||
content := page.content(include: args.include)!
|
||||
|
||||
// NEW: Process cross-collection links
|
||||
processed_content := process_cross_collection_links(content, c, mut col_dir, c.atlas)!
|
||||
processed_content := page.process_cross_collection_links(mut col_dir)!
|
||||
|
||||
mut dest_file := pathlib.get_file(path: '${col_dir.path}/${page.name}.md', create: true)!
|
||||
dest_file.write(processed_content)!
|
||||
@@ -91,25 +91,6 @@ pub fn (mut c Collection) export(args CollectionExportArgs) ! {
|
||||
json_file.write(meta)!
|
||||
}
|
||||
|
||||
// Export images
|
||||
if c.images.len > 0 {
|
||||
img_dir := pathlib.get_dir(
|
||||
path: '${col_dir.path}/img'
|
||||
create: true
|
||||
)!
|
||||
|
||||
for _, mut img in c.images {
|
||||
dest_path := '${img_dir.path}/${img.file_name()}'
|
||||
img.path.copy(dest: dest_path)!
|
||||
|
||||
if args.redis {
|
||||
mut context := base.context()!
|
||||
mut redis := context.redis()!
|
||||
redis.hset('atlas:${c.name}', img.file_name(), img.path.path)!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export files
|
||||
if c.files.len > 0 {
|
||||
files_dir := pathlib.get_dir(
|
||||
@@ -119,12 +100,13 @@ pub fn (mut c Collection) export(args CollectionExportArgs) ! {
|
||||
|
||||
for _, mut file in c.files {
|
||||
dest_path := '${files_dir.path}/${file.file_name()}'
|
||||
file.path.copy(dest: dest_path)!
|
||||
mut p2 := file.path()!
|
||||
p2.copy(dest: col_dir.path)!
|
||||
|
||||
if args.redis {
|
||||
mut context := base.context()!
|
||||
mut redis := context.redis()!
|
||||
redis.hset('atlas:${c.name}', file.file_name(), file.path.path)!
|
||||
redis.hset('atlas:${c.name}', file.file_name(), file.path()!.path)!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +204,12 @@ fn (mut p Page) process_cross_collection_links(mut export_dir pathlib.Path) !str
|
||||
panic('need to do for files too')
|
||||
}
|
||||
|
||||
for mut link in links.reverse() {
|
||||
if link.status != . {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn play(mut plbook PlayBook) ! {
|
||||
atlas_instance.scan(path: path, ignore: ignore)!
|
||||
action.done = true
|
||||
|
||||
atlas_set(atlas_instance)
|
||||
set(atlas_instance)
|
||||
}
|
||||
|
||||
// Process export actions - export collections to destination
|
||||
|
||||
@@ -146,12 +146,20 @@ fn normalize_url(url string) string {
|
||||
return url.replace(':', '/').replace('//', '/').trim('/')
|
||||
}
|
||||
|
||||
// path is needed to get the
|
||||
pub fn (self GitLocation) web_url() !string {
|
||||
println(self)
|
||||
// println(self)
|
||||
mut provider := self.provider
|
||||
if provider == 'github' {
|
||||
provider = 'github.com'
|
||||
}
|
||||
|
||||
if self.branch_or_tag == '' {
|
||||
return error('git: cannot build web_url without branch_or_tag in GitLocation: ${self}')
|
||||
}
|
||||
|
||||
// execute_opt("cd ${self.path} && git branch --show-current") !Result
|
||||
|
||||
mut url_base := 'https://${provider}/${self.account}/${self.name}'
|
||||
mut url := '${url_base}/src/branch/${self.branch_or_tag}/${self.path}'
|
||||
// if provider.contains('gitea') || provider.contains('git.') {
|
||||
@@ -163,7 +171,5 @@ pub fn (self GitLocation) web_url() !string {
|
||||
// if provider == 'gitlab' {
|
||||
// return '${url_base}/-/edit/${self.branch_or_tag}/${self.path}'
|
||||
// }
|
||||
println(url)
|
||||
$dbg;
|
||||
return url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user