ref PLG-220
- Added an `orderAttributes` override method to be able to pass
`count__likes` to the `findPage` DB helper.
- Unknowingly, without that override method in the model, it would strip
all 'non-default' queries.
- Adding that means we could remove our custom database queries and use
the regular `findPage` helper that also handles pagination.
no issue
This change adds the ability to pass a desired language/locale into
portal, as a data-locale tag added to the script that loads it.
Falls back to the previous behavior, loading from the site settings, if
no data-locale is present. (And then to 'en', if necessary.) No change
in expected behavior if data-locale is not passed.
This provides an option to run portal in a language other than the
sitewide language.
(ref: https://app.slack.com/client/T025584C4/C018EKC56JF)
- When we added i18n for search we missed gating it behind the i18n flag.
- There aren't that many translations for search yet, so it's likely not many have noticed yet
- We'll remove the flag soon, but until then, adding the flag for consistency :)
no ref
{{ghost_head}} is huge, and some power-users and theme creators want the
ability to customize what it contains. This PR makes it easier for a
theme to write custom schema, or to load a custom version of
portal/comments/search/etc, or to minimize load times by not loading
scripts where they aren't needed, in a theme-specific way.
Because ghost_head is controlled at the theme level, this gives folks in
managed hosting the new ability to load a different version of the
included app scripts (by preventing ghost_head from writing them and
adding them in manually).
Usage example: ` {{ghost_head exclude="search,portal"}} `
(empty array)
No changes to current behavior
search
The built-in sodo-search script
Includes adding the click event listener on buttons, generating the
search index, and the UI.
portal
The portal script
Handles sign-in and sign-up, payments, tips, memberships, etc, and all
the portal data-attributes.
announcement
The announcement bar javascript
If you'd like to use the announcement bar admin settings but not have it
[mess up your CLS
metric](https://www.spectralwebservices.com/blog/announcement-bar-a-review/),
this is for you.
metadata
Skips HTML tags for meta description, favicon, canonical url, robots,
referrer
Important for SEO
schema
The LD+JSON schema
Important for SEO
card_assets
Loads cards.min.css and .js
Needed on any page with a post body, unless your theme replaces them
all. Assets can also be selectively loaded with the [card_assets
override](https://ghost.org/docs/themes/content/?ref=spectralwebservices.com#editor-cards)
comment_counts
Loads the comment_counts helper
Needed if the page is using {{comments}} or data-ghost-comment-count
attribute
social_data
Produces the og: and twitter: attributes for social media sharing and
previews
Required for good social media cards
cta_styles
Removes the call to action (CTA) styles
Used for member signup and CTA cards - may be overwritten by your theme
already
ref https://linear.app/ghost/issue/ONC-506
- adding `context` with the returned API response makes the logged error much more useful as without it we only log the status code which misses any details for why the failure occurred
no issue
This PR adds the ability to translate the strings that appear in the
newsletter as boilerplate text, using i18next.
Variables are in single mustaches ( `{date}` ) in the translation
strings (rather than `{{date}}`), because these strings occur both the
email template.hbs and also .js files. That necessitated a separate
namespace.
This PR also includes changes to the newsletter button ("more like
this", "less like this", "comment") that were previously delivered on
desktop as images that included the text. @sanne-san provided a rework
that removed text-as-image from the desktop buttons, and allows more
shared code between the two layouts, along with making the buttons
translatable.
Example usage - handlebars
```
<h3 class="latest-posts-header">{{t 'Keep reading'}}</h3>
{{{t 'By {authors}' authors=post.authors }}}
```
(NOTE: triple { required because of possible & )
Example usage - javascript
```
getValue: (member) => {
if (member.status === 'comped') {
return t('complimentary');
}
if (this.isMemberTrialing(member)) {
return t('trialing');
}
// other possible statuses: t('free'), t('paid') //
return t(member.status);
}
```
---------
Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
Co-authored-by: Steve Larson <9larsons@gmail.com>
ref
https://linear.app/ghost/issue/AP-540/clicking-comment-icon-on-posts-and-likes-tabs-of-your-profile-doesnt
- We want to open posts in the drawer from multiple views (Inbox,
Profile etc.) and this change allows us to do so by pulling
`handleViewContent` from `Inbox.tsx` into a utility function. At the
same time, we’ve simplified the function so it uses less props to
achieve the same functionality.
- Also added a simple fix for scrolling the reply-box into view when
opening a long `article` by clicking on the reply icon. We probably
still need to figure out a more robust solution, because the height of
the `iframe` and the fact it takes some time to load it sometimes gets
in the way.
Co-authored-by: Michael Barrett <mike@ghost.org>
fix https://linear.app/ghost/issue/ENG-1105/settingscacheget-is-slow
- through profiling and flamegraphs, we can see that `_doGet` is one of
the bottlenecks during high traffic times, sometimes taking up to 20%
of the CPU time when hammering Ghost with `wrk`
- this is because, for the majority of settings cache lookup, we're
running `JSON.parse`, which blocks the main thread
- whilst we're only parsing small strings, we're doing it a LOT,
sometimes hundreds of times per request, which adds up
- this code just throws most deserializing at `JSON.parse`, so if we can
stop it from doing that, it'd be a huge win
- my initial attempts here were to convert the _doGet function to a
smarter deserializing, by looking up `cacheEntry.type` and acting
accordingly
- however, it became a bit of a logical nightmare, and difficult to
reason about for now (i still think we should do it)
- therefore, I'm just doing to add a hotpath fix to catch 99% of
usecases, which is checking the type of the cache entry and returning
the value if it's a string
- on a trivial benchmark locally, this causes Ghost to return 30% more
requests per second!!
ref PLG-220
- Improved `getBestComments` service to paginate correctly since we're
using a custom query to determine the top comments that goes beyond the
scope of what `findPage` is capable of.
- Updated CommentsController and CommentsService to support custom order
parameters.
- Added tests
no issue
- The browser test output in CI is really noisy, because the `NX_DAEMON`
doens't run in CI, but we're trying to use NX to watch and rebuild the
typescript modules. This is outputting a ton of "NX Daemon is not
running" type of errors, which make it difficult to sift through the
actual test results.
- We don't actually need to watch the typescript files, we just need to
build them once before starting. This is defined as an NX dependency for
the browser tests target, so we don't need to explicitly build the TS
packages at all. Removing the typescript watch & build command removes
the noisy errors, without impacting how the tests actually run.
no issue
- When stopping `yarn dev` with ctrl+c in the dev container, you'd get
an error because the container doens't have `ps` installed, which is
used by node under the hood. Adding this dependency fixed the error so
`yarn dev` (and other commands) exit cleanly
no issue
- filtering was previously added to breadcrumbs but that wasn't enough to clean up Sentry reports
- added filtering to the `beforeSend` hook too so reports don't get cluttered with unhelpful XHR noise
no issue
- The Dev Container didn't have the Github CLI installed, so this adds
that using Dev Container
"[features](https://containers.dev/implementors/features/)"
- It also adds oh-my-zsh and a few plugins that are nice to have when
developing.
no issue
- When creating a dev container, the onCreateCommand script will try to
setup the git remotes according to the environment variables defined for
e.g. `$GHOST_UPSTREAM`. There was a bug that caused the `origin` remote
to successfully be renamed to `$GHOST_UPSTREAM`, but the `origin` remote
was not being created successfully on the first try. This commit fixes
that bug.
no issue
- Added function to Dev Container onCreateCommand to setup git remotes
when creating the Dev Container
- If `$GHOST_UPSTREAM` is set, it will rename the default `origin`
remote to its value
- It will also update the remotes for the submodules, otherwise `yarn
main` will fail
- If `$GHOST_FORK_REMOTE_URL` is set, it will add it as `origin`, or the
value of `$GHOST_FORK_REMOTE_NAME` if set.
- If `$GHOST_FORCE_SSH` is set to `true`, it will change all remotes
URL's to use ssh instead of https
no issue
- The onCreateCommand was previously a bash script, which made it a bit
more challenging to read and make changes to it. This commit converts it
to JavaScript so it will be easier to make updates to it.
ref https://app.incident.io/ghost/incidents/117
- the authenticate call made as part of signup was missed as part of the update when we adjusted the params for `cookie` authenticator's `authenticate` method in Admin so it could switch behaviour for 2fa
- fixed the authenticate call params and updated our mocked `/session` endpoint to check for expected POST data which would have let tests catch this error
refs
https://linear.app/ghost/issue/ENG-1686/mail-auto-configuration-doesnt-work
- Previously the `mail` configuration that is auto-generated didn't work
because the `from` address wasn't being set, and requests were
consequently failing due to some Mailgun internal validation.
- This change requires the `MAILGUN_FROM_ADDRESS` environment variable
to be set for it to automatically configure the `mail` block, and if it
is, it adds it as `mail.from`. Now with all three of
`MAILGUN_SMTP_AUTH`, `MAILGUN_SMTP_PASS` and `MAILGUN_FROM_ADDRESS`
setup, transactional emails work out of the box in the Dev Container.