Skip to content

Diff/updates for customized themes #3803

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

Open
arunpersaud opened this issue Dec 13, 2024 · 2 comments
Open

Diff/updates for customized themes #3803

arunpersaud opened this issue Dec 13, 2024 · 2 comments

Comments

@arunpersaud
Copy link
Contributor

I'm using an existing theme, but did some very small modifications by copying some templates using 'theme -c' and editing them.

Over time the theme might be updated and it would be great to a) be able to see if there are updates available and b) see the diffs between my templates and the original theme.

I can do the diffs manually using git, e.g. delete the file in the themes directory, do a new 'theme -c' , and then run git diff, but I would need to do this for every single file and then also checkout the original file again. Perhaps a 'nikola theme diff' would be an option?

Another suggestion/question: when I use '--parent=' to specify a non-base theme for the '-c' command is there a way to find out where the file came from? For git tracked themes, it would be great to have the git version and url in the header of custom templates, so that one can figure out where they came from and perhaps manually can look for updates in the theme;)

@arunpersaud
Copy link
Contributor Author

I might give this a try. As far as I understand a custom template does have the parent defined and so it shouldn't be too hard to run a diff over all files, perhaps using the python built-in difflib module. One thing I'm not sure about is how the command would be best implemented. I assume it would go into plugin/command/theme.py ? Would one also create a diff task that compare two files and then have theme.py issue a task for each custom template? Or just do everything in theme.py?

arunpersaud pushed a commit to arunpersaud/nikola that referenced this issue Mar 7, 2025
arunpersaud pushed a commit to arunpersaud/nikola that referenced this issue Mar 11, 2025
@arunpersaud
Copy link
Contributor Author

Think I got it working. I'm iterating over all custom templates and using the built-in functions to find the correct version in a given theme to compare to and then just use difflib to print the changes.

arunpersaud pushed a commit to arunpersaud/nikola that referenced this issue Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant