Skip to content

Subdirectory Support - Email SSL Support - Federation Improvements - Mermaid Support - #1658

Open
savagebread wants to merge 16 commits into
writefreely:developfrom
savagebread:subdirectory-support-ssl-email-federation-improvements
Open

Subdirectory Support - Email SSL Support - Federation Improvements - Mermaid Support#1658
savagebread wants to merge 16 commits into
writefreely:developfrom
savagebread:subdirectory-support-ssl-email-federation-improvements

Conversation

@savagebread

@savagebread savagebread commented May 7, 2026

Copy link
Copy Markdown

[Describe the pull request here...]

no don't make me use wordpress for seo no please no please don't make me do it

Changes:

1. Subdirectory Support

  • Added subdirectory config option in config.ini, allowing WriteFreely to be hosted at a path prefix (e.g. example.com/blog/).
  • New AppCfg methods on the config struct:
    • SubdirectoryPath() — normalizes the configured subdir path
    • PrefixPath(path) — prepends the subdir prefix to any local path
    • AbsoluteURL(path) — builds a full absolute URL
    • AbsoluteHost() — returns the canonical host (with subdir stripped)
  • All routes, templates, and rendering logic updated to use these helpers so links and asset URLs are correct under a subdir deployment.
  • All templates updated to use a {{subdir}} template variable for asset and navigation paths.
  • Font and icon CSS paths corrected for subdir hosting (less/fonts.less, less/icons.less).
  • Tests added in collections_subdir_test.go to validate path generation.

2. ActivityPub / Federation Improvements

  • Introduced ExtendedPerson struct wrapping the upstream activitystreams.Person to add the image (banner/header) field, which is part of the AP spec and supported by Mastodon but absent from the upstream library.
  • PersonObject() now populates the following fields from collection settings:
    • icon — avatar/profile picture
    • image — header/banner image
    • name — display name
    • summary — bio/description
  • New federateActor() function sends an Update{Person} activity to all followers whenever a collection's profile is updated, so changes to bio, display name, avatar, and header propagate to Mastodon and other ActivityPub servers in real time.
  • collections.go now calls federateActor after saving collection metadata.
  • All ActivityPub activity posts use AbsoluteHost() to ensure correct absolute URLs.

3. Mermaid Diagram Rendering

  • Added static/js/mermaid.min.js — bundled locally, no CDN dependency.
  • templates/include/post-render.tmpl gains a {{define "mermaid"}} block that:
    • Detects <code class="language-mermaid"> blocks in rendered posts
    • Replaces them with <div class="mermaid"> elements
    • Lazy-loads the Mermaid library from {{subdir}}/js/mermaid.min.js
    • Calls mermaid.initialize() and mermaid.run()
    • Post-processes SVG text colors for theme consistency
  • Works correctly under subdirectory deployments via the {{subdir}} prefix.

4. Additional Fixes

  • Mailer: SSL/TLS support added (mailer/mailer.go, email.go).
  • Markdown rendering: Removed dead alterShortCodeEmailSubForm helper and spam honeypot injection from the live preview render endpoint.
  • Base URLs: Fixed relative vs. absolute base URL construction in postrender.go — removed leading / that caused double-slashes with the subdir prefix.
  • Chorus mode: Hashtag prefix now uses cfg.App.PrefixPath("/read/t/") and mention prefix uses cfg.App.AbsoluteURL("/@/") for correct subdir-aware URLs.

5. Test Coverage

Significant new tests added across:

Package / File Coverage added
appstats/appstats_test.go Stats aggregation
author/author_test.go Author URL helpers
config/config_test.go Config parsing and subdir path logic
config/funcs_test.go Config helper functions
config/validation_test.go Config validation rules
db/dialect_test.go SQL dialect handling
db/index_test.go Index creation
db/raw_test.go Raw query execution
parse/posts_test.go Post parsing
postrender_test.go Markdown rendering pipeline
posts_test.go Post model logic
semver_test.go Semantic version comparison
spam/spam_test.go Spam detection
request_test.go HTTP request helpers
routes_test.go Route registration and resolution
activitypub_test.go ActivityPub actor and activity handling
email_test.go Email sending

Photo Examples:

Mermaid Rendering in blog post

image

Branding Settings

image

Mermaid Setting

image
  • I have signed the CLA

@savagebread savagebread changed the title Subdirectory support ssl email federation improvements Subdirectory Support - SSL Support - Federation Improvements - Mermaid Support May 7, 2026
@savagebread

savagebread commented May 7, 2026

Copy link
Copy Markdown
Author

Found a bug that breaks text, in this case STRONG formatted text, out of the blog column, need to fix, and examine if other formatted text does this as well from the mermaid changes.

was actually my blogs custom css and not the code itself

@savagebread

savagebread commented May 7, 2026

Copy link
Copy Markdown
Author

@thebaer hi Matt,

I’m quite fond of the philosophy behind writefreely, it’s simple, customisable, smart, with the foundation of golang to support it (Working with it for 3 years professionally now, I believe it’s a great language for scale.)

Ideally, I would have broken these into separate PRs entirely, but my feature scope became quite broad and i got ahead of myself trying to see it all work together, but each commit or cluster of commits should not be horribly coupled to one another, if at all.

However, I’m sure I’ve introduced some new quirks notably in ui, so please feel free to tear this apart, and I will do my due diligence in making sure this code runs correctly. I have it running on my own blog to test everything too. I hope these changes can add a lot of value to writefreely.

@savagebread
savagebread marked this pull request as draft May 7, 2026 15:58
@savagebread
savagebread marked this pull request as ready for review May 7, 2026 21:30
@savagebread
savagebread force-pushed the subdirectory-support-ssl-email-federation-improvements branch from 82aed0a to 4396688 Compare May 7, 2026 23:35
@savagebread
savagebread marked this pull request as draft May 8, 2026 06:07
@savagebread savagebread changed the title Subdirectory Support - SSL Support - Federation Improvements - Mermaid Support Subdirectory Support - Email SSL Support - Federation Improvements - Mermaid Support May 8, 2026
@savagebread
savagebread marked this pull request as ready for review May 17, 2026 18:29
@thebaer

thebaer commented May 19, 2026

Copy link
Copy Markdown
Member

Hey @savagebread, I appreciate you having a go at all of this! I would love to get everything merged that makes sense. But in order for me to properly review this, I do need this broken up into separate PRs, ideally by overall functionality and then the individual small fixes (for example, I'd want to know why alterShortCodeEmailSubForm and the subscription honeypot was removed).

If you want to start with the subdirectory changes as a branch and set all other changes to be merged into that one, I think that would be a decent strategy. Thanks again for taking an interest in this!

@savagebread

Copy link
Copy Markdown
Author

Sweet!
I'll definitely break these up, I've been busy with some other projects, but intend to complete this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants