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

Problem disabling create_index_from_dir_structure #327

Closed
hgrw opened this issue Aug 6, 2022 · 3 comments
Closed

Problem disabling create_index_from_dir_structure #327

hgrw opened this issue Aug 6, 2022 · 3 comments

Comments

@hgrw
Copy link

hgrw commented Aug 6, 2022

I would like to disable create_index_from_dir_structure but get an error when doing it. I have found this issue on all the obsidianhtml-generated sites I maintain which have default styling. Perhaps this feature is needed to generate the file tree - if so a note in the docs would be great.

PS - loving obsidianhtml, as usual.

To reproduce:

  1. Create a trivial documentation structure (eg a home page that links to an empty page elsewhere in the vault)
  2. Create fresh config file with obsidianhtml -gc
  3. Set required parameters to generate site with trivial documentation structure
  4. Set create_index_from_dir_structure to False

Observe:

pipenv run obsidianhtml -i config/obsidianhtml.yaml
> COPYING VAULT /home/mars/git/hgrwilson.com/website TO /tmp/tmp_b2z_ity
< COPYING VAULT: Done
> CLEARING OUTPUT FOLDERS
> CREATING OUTPUT FOLDERS
> COMPILING MARKDOWN FROM OBSIDIAN CODE (/tmp/tmp_b2z_ity/Site-Home.md)
> COMPILING HTML FROM MARKDOWN CODE (/home/mars/git/hgrwilson.com/website/public/md/index.md)
index.md
	> SECOND PASS HTML
Traceback (most recent call last):
  File "/home/mars/.local/share/virtualenvs/hgrwilson.com-mIntjDuM/bin/obsidianhtml", line 8, in <module>
    sys.exit(main())
  File "/home/mars/.local/share/virtualenvs/hgrwilson.com-mIntjDuM/lib/python3.10/site-packages/obsidianhtml/__init__.py", line 837, in main
    dir_list = pb.treeobj.BuildIndex(current_page=node['url'])
AttributeError: 'PicknickBasket' object has no attribute 'treeobj'
@dwrolvink
Copy link
Collaborator

dwrolvink commented Aug 6, 2022

Yes that is correct, the following block causes this error:

            if pb.gc('toggles/features/styling/add_dir_list', cached=True):
                if dir_repstring in html:
                    dir_list = pb.treeobj.BuildIndex(current_page=node['url'])

and pb.treeobj is loaded here:

        if pb.gc('toggles/features/create_index_from_dir_structure/enabled'):
            rel_output_path = pb.gc('toggles/features/create_index_from_dir_structure/rel_output_path')
            op = paths['html_output_folder'].joinpath(rel_output_path)

            print(f'\t> COMPILING INDEX FROM DIR STRUCTURE ({op})')
            treeobj = CreateIndexFromDirStructure(pb, pb.paths['html_output_folder'])
            pb.treeobj = treeobj
            treeobj.html = treeobj.

So for toggles/features/styling/add_dir_list = True one also needs
toggles/features/create_index_from_dir_structure/enabled = True. So for now the workaround would be to set:

toggles:
  features:
    create_index_from_dir_structure:
      enabled: True
      rel_output_path: 'obs.html/dir_index.html'
      styling: 
        show_icon: False

I guess the best solution here is to add a check whether pb.treeobj exists and then load it in anyways if it doesn't yet.

Just curious, why did you disable the create_index_from_dir_structure feature?
Just not to have the icon there anymore?

dwrolvink added a commit to dwrolvink/obsidian-html that referenced this issue Aug 6, 2022
dwrolvink added a commit that referenced this issue Aug 6, 2022
@dwrolvink
Copy link
Collaborator

Should be fixed in master now

@hgrw
Copy link
Author

hgrw commented Aug 8, 2022

Yeah I just wanted to get rid of the icon. Cheers!

@hgrw hgrw closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants