Skip to content

Link gutenbergsite to autocat3 via git submodule#186

Draft
Thenlie wants to merge 5 commits intogutenbergtools:masterfrom
Thenlie:devx-submodule
Draft

Link gutenbergsite to autocat3 via git submodule#186
Thenlie wants to merge 5 commits intogutenbergtools:masterfrom
Thenlie:devx-submodule

Conversation

@Thenlie
Copy link
Contributor

@Thenlie Thenlie commented Aug 16, 2025

@gbnewby requested an example of the submodule approach in #185. This PR is that example.

Overview

I started tracking gutenbergsite within autocat3 via submodule

git submodule add git@github.com:gutenbergtools/gutenbergsite.git

We can then checkout only the necessary files using sparse-checkout:

git sparse-checkout set 'gutenberg/*.css' 'gutenberg/*.png' 'pics' --no-cone

This command can be added to a script so it is easier for other devs. It can also be updated as new files are added.
When working on the project, you can simply git pull the upstream changes from gutenbergsite.

The other changes attempt to dynamically point assets to the submodule directory. This is being done dynamically so it can drop in to the dev and prod environments and still work.

@eshellman
Copy link
Contributor

I think your dotenv import duplicates what pipenv already does? I don't want to be supporting multiple environment managers, cuz then we'll need to manage the managers

</span>
<img py:if="e.thumb_url"
class="cover-thumb" src="${e.thumb_url}" alt="" />
class="cover-thumb" src="${os.dev_base_path}${e.thumb_url}" alt="" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're writing a script to pull assets into static, why not do the same for the other assets? (note that some of the _includes files come from the dev autocat3 like this:
/usr/bin/wget --quiet -O ${BUILD}/_includes/popular_covers.html "http://[autocat3]:8000/covers/medium/popular/10"
(jekyll script in ebookconverter repo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, this is more-or-less just linking static assets from gutenbergsite to autocat. Definitely would be interesting to pull other assets in as well. But right now there is no script involved. Everything will work when submodules are fetched.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically, it's a base url, not a path. And why only "dev"?

@Thenlie
Copy link
Contributor Author

Thenlie commented Aug 17, 2025

I think your dotenv import duplicates what pipenv already does? I don't want to be supporting multiple environment managers, cuz then we'll need to manage the managers

Thanks Eric, didn't realize pipenv also has env variables. I will update to use their system. Agree we should only have one.

@eshellman
Copy link
Contributor

Something like this would really help! When I tried it, I got lost in an unfamiliar git zone; will need more guidance on the git submodule part. For example, if all I want to do is put the gutenbergsite stuff into a CherryPy static directory, (without bonking my autocat3 repo) what are the steps? Do I need to gitignore the static directory in my autocat3 repo?

@Thenlie
Copy link
Contributor Author

Thenlie commented Aug 27, 2025

Something like this would really help! When I tried it, I got lost in an unfamiliar git zone; will need more guidance on the git submodule part. For example, if all I want to do is put the gutenbergsite stuff into a CherryPy static directory, (without bonking my autocat3 repo) what are the steps? Do I need to gitignore the static directory in my autocat3 repo?

Apologies for the delay here.

@eshellman You shouldn't need any .gitignore changes for this to work. Git handles it all under the hood with .gitmodules. We will have a gutenberg folder in the repo which is a link to the gutenberg repo. It does not actually commit all the individual files.

Here are the complete steps:

  1. Pull down and checkout my branch git pull Thenlie:devx-submodule
  2. Initialize the submodule git submodule update --init
  3. (optional) Spare checkout gutenberg so we only see necessary files cd gutenberg && git sparse-checkout set 'gutenberg/*.css' 'gutenberg/*.png' 'pics' --no-cone

Let me know if you have any other questions or if these steps don't work for you.

EDIT: I forgot to mention, the submodule points to a specific commit in the gutenberg repo. When devs run git submodule update it will pull the code from that commit. We can change this easily with git submodule update --remote. This will pull latest changes and update the commit the submodule references.

@eshellman
Copy link
Contributor

the spare-checkout then omits the autocat 3 files, how do I get both?

@Thenlie
Copy link
Contributor Author

Thenlie commented Aug 28, 2025

the spare-checkout then omits the autocat 3 files, how do I get both?

It sounds like you might be running the command from the autocat3 repo instead of within the submodule. You need to be in the gutenberg directory. If you run git log you should see the gutenbergsite commits.

@eshellman
Copy link
Contributor

eshellman commented Aug 28, 2025 via email

@Thenlie
Copy link
Contributor Author

Thenlie commented Aug 29, 2025

In the autocat3 repo.

@eshellman
Copy link
Contributor

When I try to switch to this branch with Github Desktop from a branch that has not had submodule set I get:

fatal: could not reset submodule index

To avoid that I need to run git submodule add before switching to the branch with the submodule.
So this branch would need an extra step (one-time?) to the deployment procedure - on local. maybe, maybe not for prod servers.

another way to manage this is to add the extra env params so that devs can use submodules or copies of the gutenberg directory so we don't need to alter the prod deployments until we have more experience.

@Thenlie
Copy link
Contributor Author

Thenlie commented Sep 1, 2025

Yes that's correct. And my intent was for this to only impact local builds. Dev and Prod should both still use the current set up.

It should already be set up to use ENV params to point to the static directory you want. If someone would prefer to skip the submodule setup, they could just copy the assets to ASSET_DIR or point that value to their local gutenbergsite repo.

If we want to use something like this in prod, IMO it would make more sense to simply combine the repos.

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

Successfully merging this pull request may close these issues.

2 participants