Skip to content

Commit

Permalink
FIX: expire assets when CSS changes FIX: missing translation on share…
Browse files Browse the repository at this point in the history
… page (#528)

* FIX: expire assets when CSS changes
FIX: missing translation on share page

Also add trivial image styling

* oops not needed
  • Loading branch information
SamSaffron committed Mar 13, 2024
1 parent 9d92dd7 commit ea5c386
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
15 changes: 15 additions & 0 deletions app/helpers/discourse_ai/ai_bot/shared_ai_conversations_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true
module DiscourseAi
module AiBot
module SharedAiConversationsHelper
# bump up version when assets change
# long term we may want to change this cause it is hard to remember
# to bump versions, but for now this does the job
VERSION = "1"

def share_asset_url(short_path)
::UrlHelper.local_cdn_url("/plugins/discourse-ai/ai-share/#{short_path}?#{VERSION}")
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
<meta name="twitter:title" content="<%= @shared_conversation.title %>">
<meta name="twitter:description" content="<%= @shared_conversation.formatted_excerpt %>">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="<%= ::UrlHelper.local_cdn_url("/plugins/discourse-ai/ai-share/share.css") %>">
<link rel="stylesheet" href="<%= ::UrlHelper.local_cdn_url("/plugins/discourse-ai/ai-share/highlight.min.css") %>">
<link rel="stylesheet" href="<%= share_asset_url("share.css") %>">
<link rel="stylesheet" href="<%= share_asset_url("highlight.min.css") %>">
<script>
window.hljs_initHighlighting = function() {
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
});
};
</script>
<script async src="<%= ::UrlHelper.local_cdn_url("/plugins/discourse-ai/ai-share/highlight.min.js") %>" onload="window.hljs_initHighlighting()" ></script>
<script async src="<%= share_asset_url("highlight.min.js") %>" onload="window.hljs_initHighlighting()" ></script>
</head>
<body>
<header class="site-header">
Expand All @@ -42,7 +42,6 @@
<span><%= @shared_conversation.llm_name %></span>
</div>
</header>

<section>
<header class="page-header">
<h1><%= @shared_conversation.title %></h1>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ en:
share_ai:
read_more: "Read full transcript"
onebox_title: "AI Conversation with %{llm_name}"
formatted_excerpt: "AI Conversation with %{llm_name}:\n %{excerpt}"
errors:
not_allowed: "You are not allowed to share this topic"
other_people_in_pm: "Personal messages with other humans cannot be shared publicly"
other_content_in_pm: "Personal messages containing posts from other people cannot be shared publicly"
failed_to_share: "Failed to share the conversation"
conversation_deleted: "Conversation share deleted successfully"
formatted_excerpt: "AI Conversation with %{llm_name}:\n %{excerpt}"
ai_bot:
personas:
cannot_delete_system_persona: "System personas cannot be deleted, please disable it instead"
Expand Down
20 changes: 15 additions & 5 deletions public/ai-share/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
--font-up-4: 1.7511em;
--font-up-3: 1.5157em;
--font-up-2: 1.3195em;
--font-up-1: 1.1487em;
--font-up-1: 1.1487em;
--font-0: 1em;
--font-down-1: 0.8706em;
--font-down-2: 0.7579em;
--font-down-1: 0.8706em;
--font-down-2: 0.7579em;
--font-down-3: 0.6599em;
--font-down-4: 0.5745em;
--font-down-5: 0.5em;
Expand Down Expand Up @@ -216,7 +216,7 @@ article {
}
article:last-of-type:hover {
border-bottom-color: transparent;
}
}
}

pre, code {
Expand Down Expand Up @@ -290,7 +290,7 @@ h1 h2 h3 h4 h5 h6 {
.post__content p:last-child {
margin-bottom: 0.4em;
}

.post__date {
color: var(--primary-500);
margin-left: auto;
Expand Down Expand Up @@ -377,3 +377,13 @@ li, p {
word-break: break-word;
}

.lightbox-wrapper .meta svg, .lightbox-wrapper .meta .informations {
display: none;
}
.lightbox-wrapper .meta .filename {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;

}
1 change: 1 addition & 0 deletions spec/requests/ai_bot/shared_ai_conversations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def share_error(key)
expect(response).to have_http_status(:success)
expect(response.headers["Cache-Control"]).to eq("max-age=60, public")
expect(response.headers["X-Robots-Tag"]).to eq("noindex")
expect(response.body).not_to include("Translation missing")
end

it "is also able to render in json format" do
Expand Down

0 comments on commit ea5c386

Please sign in to comment.