Manage Trac wiki content via git repo?

12 views
Skip to first unread message

Quinn Comendant

unread,
Sep 19, 2021, 4:29:27 PMSep 19
to trac-...@googlegroups.com
We have been using Trac to manage our company's internal wiki, but everyone responsible for working on this documentation complains about having to edit the content through the Trac GUI. They want to be able to manage the wiki content as a folder of Markdown files. They would edit files in a text editor and sync the content back up to the server. I want to support their needs, but also need to keep the wiki content published through the Trac wiki so it is accessible and editable to non-technical employees.

What is the best way to do this with Trac?

I've discovered the `trac-admin` command has `export` and `load` functions, so perhaps I could glue together an automation that regularly exports and important content. Has anyone done this before? Any potential pitfalls?

As for using Markdown, I see there is a MarkdownMacro, which supports using Markdown as a default wiki language.
https://trac-hacks.org/wiki/MarkdownMacro#MarkdownasWikiLanguage

Thanks,
Quinn

Markus Rosjat

unread,
Sep 20, 2021, 3:28:10 AMSep 20
to trac-...@googlegroups.com
Hi Quinn,

if you really want to go down this road you might consider a post commit hook for git that takes care of bringing the changed file to a point where you pick it up to stuff it into the trac db.

that said you need to think of a way to stuff it in the db.... a crud way woud be trying to figure out where and how a page is stored/added/deleted/edited and do it with some sql that a tool runs  but I am not sure if trac offers to interface somehow to bring these changes in, if so you might take a loot at that first since it will produce more sane results when it comes to storing data in the trac db.

I dont know if someone can point out more on that but i guess its a starting point to do some research

cheers

Markus 

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/20210919152918486961.22788d17%40strangecode.com.

RjOllos

unread,
Sep 21, 2021, 4:15:28 PMSep 21
to Trac Users
On Sunday, September 19, 2021 at 1:29:27 PM UTC-7 Quinn Comendant wrote:
We have been using Trac to manage our company's internal wiki, but everyone responsible for working on this documentation complains about having to edit the content through the Trac GUI. They want to be able to manage the wiki content as a folder of Markdown files. They would edit files in a text editor and sync the content back up to the server. I want to support their needs, but also need to keep the wiki content published through the Trac wiki so it is accessible and editable to non-technical employees.

 
What is the best way to do this with Trac?

I've discovered the `trac-admin` command has `export` and `load` functions, so perhaps I could glue together an automation that regularly exports and important content. Has anyone done this before? Any potential pitfalls?


Yes, I think you could probably make it work, but it will be complex to allow two modes of editing: via web interface and repository. You need some sort of locking and/or merging mechanism.

* Plugin implementing IWikiChangeListener to prevent concurrent edits and save the content to the repository after editing through the web interface
* Repository hooks to prevent concurrent edits and saving wiki content to the database on Git push

When saving a wiki page through the web interface you'd need to check if the content in the repository has changed and reject saving if the content has changed. You could do this using IWikiManipulator.

Basically, you need to implement the same checks and behavior that prevent concurrent edits to wiki pages. Changes to the repository should be locked during the save operation.

On the repository side, you need to check whether the repository is locked before allowing a push, then lock changes to the modified wiki pages while accepting the push and syncing changes to the wiki. If there are changes to the repository you can block the push and tell the user to pull and merge the changes into their clone of the repository. That's actually easier than on the wiki side since Git is good at merging.

Quinn Comendant

unread,
Sep 21, 2021, 5:18:20 PMSep 21
to trac-...@googlegroups.com
Thank you Markus and RjOllos, your answers help a lot. If I come up with a solution that works well, I'll share it with the community.

Quinn

RjOllos

unread,
Sep 21, 2021, 5:21:51 PMSep 21
to Trac Users
On Tuesday, September 21, 2021 at 2:18:20 PM UTC-7 Quinn Comendant wrote:
Thank you Markus and RjOllos, your answers help a lot. If I come up with a solution that works well, I'll share it with the community.

Quinn

 👍  It's a really cool idea that I've thought about in the past because I would like to edit all my docs out of a repository. Unfortunately, I'm not working in a team where I could push the idea right now otherwise I would love to work on implementing the solution. Maybe someday!
Reply all
Reply to author
Forward
0 new messages