diff --git a/lib/core/herocmds/atlas.v b/lib/core/herocmds/atlas.v index 8b481227..86c3a7db 100644 --- a/lib/core/herocmds/atlas.v +++ b/lib/core/herocmds/atlas.v @@ -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 @@ -111,7 +110,7 @@ fn cmd_atlas_execute(cmd Command) ! { mut update := cmd.flags.get_bool('update') or { false } mut scan := cmd.flags.get_bool('scan') or { false } mut export := cmd.flags.get_bool('export') or { false } - + // Include and redis default to true unless explicitly disabled mut no_include := cmd.flags.get_bool('no-include') or { false } mut no_redis := cmd.flags.get_bool('no-redis') or { 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') } @@ -168,20 +167,20 @@ fn cmd_atlas_execute(cmd Command) ! { if destination == '' { destination = '${atlas_path.path}/output' } - + console.print_header('Exporting collections to: ${destination}') console.print_item('Include processing: ${include}') console.print_item('Redis metadata: ${redis}') - + a.export( destination: destination reset: reset include: include redis: redis )! - + console.print_green('✓ Export complete to ${destination}') - + // Print any errors encountered during export for _, col in a.collections { if col.has_errors() { @@ -189,4 +188,4 @@ fn cmd_atlas_execute(cmd Command) ! { } } } -} \ No newline at end of file +} diff --git a/lib/data/atlas/atlas.v b/lib/data/atlas/atlas.v index a8571c88..275615a8 100644 --- a/lib/data/atlas/atlas.v +++ b/lib/data/atlas/atlas.v @@ -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()) diff --git a/lib/data/atlas/collection.v b/lib/data/atlas/collection.v index 494192d3..7b709f54 100644 --- a/lib/data/atlas/collection.v +++ b/lib/data/atlas/collection.v @@ -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()! } diff --git a/lib/data/atlas/export.v b/lib/data/atlas/export.v index bd9aaf4f..6c7f93b0 100644 --- a/lib/data/atlas/export.v +++ b/lib/data/atlas/export.v @@ -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)! } } } diff --git a/lib/data/atlas/link.v b/lib/data/atlas/link.v index dd99115d..57a361d5 100644 --- a/lib/data/atlas/link.v +++ b/lib/data/atlas/link.v @@ -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 } diff --git a/lib/data/atlas/play.v b/lib/data/atlas/play.v index 9d54c155..6b74de86 100644 --- a/lib/data/atlas/play.v +++ b/lib/data/atlas/play.v @@ -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 diff --git a/lib/develop/gittools/gitlocation.v b/lib/develop/gittools/gitlocation.v index 6068cc32..431ef090 100644 --- a/lib/develop/gittools/gitlocation.v +++ b/lib/develop/gittools/gitlocation.v @@ -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 }