Skip to content

Commit 593a139

Browse files
authored
custom ai button style (#960)
* custom ai button style * Add autostage configuration to fix staging deployment * fix * change style * add cleanup
1 parent 838cde5 commit 593a139

File tree

11 files changed

+223
-45
lines changed

11 files changed

+223
-45
lines changed

.github/workflows/clean-site.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Cleanup iotdb-website Repository
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target_branch:
7+
description: 'Branch to cleanup (asf-site or asf-staging)'
8+
required: true
9+
type: choice
10+
options:
11+
- asf-site
12+
- asf-staging
13+
- both
14+
confirm:
15+
description: 'Type "CONFIRM" to proceed with cleanup'
16+
required: true
17+
type: string
18+
19+
jobs:
20+
cleanup:
21+
runs-on: ubuntu-latest
22+
if: github.event.inputs.confirm == 'CONFIRM'
23+
24+
steps:
25+
- name: Validate confirmation
26+
if: github.event.inputs.confirm != 'CONFIRM'
27+
run: |
28+
echo "❌ Cleanup cancelled: confirmation not provided"
29+
exit 1
30+
31+
- name: Checkout iotdb-website repository
32+
uses: actions/checkout@v4
33+
with:
34+
repository: apache/iotdb-website
35+
token: ${{ secrets.IOTDB_WEBSITE_BUILD }}
36+
fetch-depth: 0
37+
ref: ${{ github.event.inputs.target_branch == 'both' && 'asf-site' || github.event.inputs.target_branch }}
38+
39+
- name: Configure Git
40+
run: |
41+
git config user.name "github-actions[bot]"
42+
git config user.email "41898282+github-actions[bot]@users.noreply. github.com"
43+
44+
- name: Cleanup asf-site branch
45+
if: github.event. inputs.target_branch == 'asf-site' || github.event.inputs.target_branch == 'both'
46+
run: |
47+
echo "🧹 Cleaning up asf-site branch..."
48+
49+
# Checkout the branch
50+
git checkout asf-site
51+
52+
# Create a new orphan branch (no history)
53+
git checkout --orphan asf-site-new
54+
55+
# Add all current files
56+
git add -A
57+
58+
# Create initial commit
59+
git commit -m "chore: reset repository history to reduce size
60+
61+
Previous repository size: ~5.9GB
62+
This commit resets the Git history to start fresh.
63+
64+
Ref: Repository cleanup initiative"
65+
66+
# Delete old branch and rename new one
67+
git branch -D asf-site || true
68+
git branch -m asf-site
69+
70+
# Force push (this removes all history)
71+
git push -f origin asf-site
72+
73+
echo "✅ asf-site branch cleaned successfully"
74+
75+
- name: Cleanup asf-staging branch
76+
if: github.event.inputs.target_branch == 'asf-staging' || github.event.inputs.target_branch == 'both'
77+
run: |
78+
echo "🧹 Cleaning up asf-staging branch..."
79+
80+
# Fetch and checkout the staging branch
81+
git fetch origin asf-staging: asf-staging
82+
git checkout asf-staging
83+
84+
# Create a new orphan branch (no history)
85+
git checkout --orphan asf-staging-new
86+
87+
# Add all current files
88+
git add -A
89+
90+
# Create initial commit
91+
git commit -m "chore: reset repository history to reduce size
92+
93+
Previous repository size: ~5.9GB
94+
This commit resets the Git history to start fresh.
95+
96+
Ref: Repository cleanup initiative"
97+
98+
# Delete old branch and rename new one
99+
git branch -D asf-staging || true
100+
git branch -m asf-staging
101+
102+
# Force push (this removes all history)
103+
git push -f origin asf-staging
104+
105+
echo "✅ asf-staging branch cleaned successfully"
106+
107+
- name: Summary
108+
run: |
109+
echo "## Cleanup Summary" >> $GITHUB_STEP_SUMMARY
110+
echo "" >> $GITHUB_STEP_SUMMARY
111+
echo "✅ Successfully cleaned branch(es): **${{ github.event.inputs.target_branch }}**" >> $GITHUB_STEP_SUMMARY
112+
echo "" >> $GITHUB_STEP_SUMMARY
113+
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
114+
echo "1. Wait for GitHub to run garbage collection (may take hours)" >> $GITHUB_STEP_SUMMARY
115+
echo "2. Check repository size at: https://github.com/apache/iotdb-website" >> $GITHUB_STEP_SUMMARY
116+
echo "3. All users should re-clone the repository to get the cleaned version" >> $GITHUB_STEP_SUMMARY
117+
echo "" >> $GITHUB_STEP_SUMMARY
118+
echo "### ⚠️ Important Notes" >> $GITHUB_STEP_SUMMARY
119+
echo "- All commit history in the cleaned branch(es) has been removed" >> $GITHUB_STEP_SUMMARY
120+
echo "- The repository size reduction may take some time to reflect on GitHub" >> $GITHUB_STEP_SUMMARY
121+
echo "- Current deployments are not affected and will continue to work" >> $GITHUB_STEP_SUMMARY

.github/workflows/site-build.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ jobs:
3737
env:
3838
NODE_OPTIONS: --max_old_space_size=8192
3939
run: pnpm build
40-
40+
41+
- name: Deploy staging website
42+
env:
43+
IOTDB_WEBSITE_BUILD: ${{ secrets.IOTDB_WEBSITE_BUILD }}
44+
run: |
45+
git config --global url."https://asf-ci-deploy:[email protected]/apache/".insteadOf "https://github.com/apache/"
46+
git config --global user.name github-actions
47+
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
48+
npm run deploy:staging
49+
4150
linksCheck:
4251
runs-on: ubuntu-latest
4352
if: github.event_name == 'pull_request'
@@ -59,7 +68,7 @@ jobs:
5968
- name: Test build website
6069
env:
6170
NODE_OPTIONS: --max_old_space_size=8192
62-
run: pnpm run check-links
71+
run: pnpm run check-links
6372

6473
deploy:
6574
runs-on: ubuntu-latest

deploy.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ghpages.publish(
2525
repo: 'https://github.com/apache/iotdb-website.git',
2626
message: 'Site checkin for project iotdb-website',
2727
dotfiles: true,
28+
history: false,
2829
},
2930
(err) => {
3031
if (err instanceof Error) {

deploy_staging.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ghpages.publish(
2525
repo: 'https://github.com/apache/iotdb-website.git',
2626
message: 'Site checkin for project iotdb-website',
2727
dotfiles: true,
28+
history: false,
2829
},
2930
(err) => {
3031
if (err instanceof Error) {

src/.vuepress/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ import {
2626
} from 'vuepress/client';
2727
import useLegacyRoute from './composables/useLegacyRoute.js';
2828
import DocSearch from './components/DocSearch.vue';
29+
import AIButton from './components/AIButton.vue';
2930
import Layout from './components/SidebarLayout.vue';
3031
import { getDocVersion } from './utils/index.js';
3132

3233
export default defineClientConfig({
3334
enhance: ({ app }) => {
3435
app.component('DocSearch', DocSearch);
36+
app.component('AIButton', AIButton);
3537
},
3638
setup() {
3739
useLegacyRoute();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<div>
3+
<button id="custom-ask-ai-button">
4+
✨ Ask AI
5+
</button>
6+
</div>
7+
</template>
8+
<style lang="scss">
9+
#custom-ask-ai-button {
10+
background-color: transparent;
11+
border: 1px solid #9E2878;
12+
color: #9E2878;
13+
padding: 8px 16px;
14+
border-radius: 8px;
15+
font-size: 14px;
16+
cursor: pointer;
17+
transition: all 0.3s ease;
18+
19+
&:hover {
20+
background-color: #9E2878;
21+
color: #FFFFFF;
22+
}
23+
}
24+
25+
.AI-Button {
26+
margin-left: 0;
27+
border-radius: 8px;
28+
all: unset;
29+
align-items: center;
30+
background-color: var(--docsearch-searchbox-background);
31+
border: 1px solid var(--docsearch-subtle-color);
32+
border-radius: 4px;
33+
color: var(--docsearch-muted-color);
34+
cursor: pointer;
35+
display: flex;
36+
height: 36px;
37+
justify-content: space-between;
38+
padding: 0 8px;
39+
-webkit-user-select: none;
40+
-moz-user-select: none;
41+
user-select: none;
42+
}
43+
</style>

src/.vuepress/config.ts

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,47 +84,43 @@ _paq.push(['enableLinkTracking']);
8484
})();
8585
`,
8686
],
87-
// [
88-
// 'script',
89-
// {
90-
// async: true,
91-
// src: 'https://widget.kapa.ai/kapa-widget.bundle.js',
92-
// 'data-website-id': '2d37bfdd-8d98-40ba-9223-9d4f81bfb327',
93-
// // 'data-language': 'zh',
94-
// 'data-project-name': 'Apache IoTDB',
95-
// 'data-project-color': '#9E2878',
96-
// 'data-button-image-height': '0px',
97-
// 'data-button-image-width': '0px',
98-
// // 'data-button-bg-color': '#FFF',
99-
// // 'data-button-text-color': '#9E2878',
100-
// 'data-project-logo': 'https://iotdb.apache.org/slogo.png',
101-
// 'data-button-position-right': '16px',
102-
// 'data-button-position-bottom': '120px',
103-
// 'data-button-height': '50px',
104-
// 'data-button-width': '50px',
105-
// 'data-button-text': 'Ask',
106-
// 'data-modal-image-width': '150px',
107-
// 'data-modal-title': 'AI Docs',
108-
// // 'data-modal-disclaimer':
109-
// // 'This is a custom LLM with access to all [Kapa documentation](https://docs.kapa.ai).',
110-
// // 'data-modal-example-questions':
111-
// // 'How do I get started?,How to add example questions?',
112-
// 'data-user-analytics-fingerprint-enabled': 'true',
113-
// // 'data-modal-x-offset': '0',
114-
// // 'data-modal-y-offset': '0',
115-
// // 'data-modal-with-overlay': 'false',
116-
// // 'data-modal-inner-flex-direction': 'column',
117-
// // 'data-modal-inner-justify-content': 'end',
118-
// // 'data-modal-inner-max-width': '500px',
119-
// // 'data-modal-inner-position-left': 'auto',
120-
// // 'data-modal-inner-position-right': '0',
121-
// // 'data-modal-inner-position-bottom': '0',
122-
// // 'data-modal-inner-position-top': '0',
123-
// // 'data-modal-size': '100vh',
124-
// // 'data-modal-lock-scroll': 'false',
125-
// // 'data-modal-header-bg-color': '#fff',
126-
// },
127-
// ],
87+
[
88+
'script',
89+
{
90+
async: true,
91+
src: 'https://widget.kapa.ai/kapa-widget.bundle.js',
92+
'data-website-id': '2d37bfdd-8d98-40ba-9223-9d4f81bfb327',
93+
// 'data-language': 'zh',
94+
'data-project-name': 'Apache IoTDB',
95+
'data-project-color': '#FFFFFF',
96+
'data-button-z-index': '1999',
97+
'data-button-padding': '4px',
98+
'data-button-border-radius': '4px',
99+
'data-button-image-height': '24px',
100+
'data-button-image-width': '20px',
101+
'data-button-text-color': '#9E2878',
102+
'data-project-logo': 'https://iotdb.apache.org/img/logo.svg',
103+
'data-button-position-right': '16px',
104+
'data-button-position-bottom': '8px',
105+
'data-button-height': '56px',
106+
'data-button-width': '48px',
107+
'data-button-text': 'Ask',
108+
// 'data-button-hide': 'true',
109+
'data-modal-override-open-selector': '#custom-ask-ai-button',
110+
'data-modal-image-width': '150px',
111+
'data-modal-title': 'AI Docs',
112+
'data-modal-title-color': '#9E2878',
113+
'data-modal-disclaimer':
114+
'This is a custom LLM for Apache IoTDB with access to all [documentation](iotdb.apache.org/docs/), [GitHub Open Issues, PRs and READMEs](github.com/apache/iotdb).&#10;&#10;Companies deploy assistants like this ([built by kapa.ai](https://kapa.ai)) on docs via [website widget](https://docs.kapa.ai/integrations/website-widget) (Docker, Reddit), in [support forms](https://docs.kapa.ai/integrations/support-form-deflector) for ticket deflection (Monday.com, Mapbox), or as [Slack bots](https://docs.kapa.ai/integrations/slack-bot) with private sources.',
115+
116+
// 'data-modal-example-questions':
117+
// 'How do I get started?,How to add example questions?',
118+
'data-user-analytics-fingerprint-enabled': 'true',
119+
'data-consent-required': 'true',
120+
'data-consent-screen-disclaimer':
121+
"By clicking <I agree, let's chat>, you consent to the use of the AI assistant in accordance with kapa.ai's [Privacy Policy](https://www.kapa.ai/content/privacy-policy). This service uses reCAPTCHA, which requires your consent to Google's [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms). By proceeding, you explicitly agree to both kapa.ai's and Google's privacy policies.",
122+
},
123+
],
128124
],
129125

130126
shouldPrefetch: false,

src/.vuepress/public/.asf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
staging:
2121
profile: ~
2222
whoami: asf-staging
23+
autostage: "*"
2324

2425
publish:
2526
whoami: asf-site

src/.vuepress/public/.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RewriteRule . /404.html [L]
66

77
ErrorDocument 404 /404.html
88

9-
Header set Content-Security-Policy "default-src data: blob: 'self' *.apache.org *.githubusercontent.com *.github.com *.algolia.net *.algolianet.com *.kapa.ai www.google.com *.gstatic.com *.apachecon.com *.communityovercode.org 'unsafe-inline' 'unsafe-eval'; frame-src 'self' www.google.com data: blob:; frame-ancestors 'self'; worker-src 'self' data: blob:; img-src 'self' blob: data: https: *.apache.org www.apachecon.com; style-src 'self' 'unsafe-inline' data:;"
9+
Header set Content-Security-Policy "default-src data: blob: 'self' *.apache.org *.kapa.ai *.githubusercontent.com *.googleapis.com *.google.com *.run.app *.gstatic.com *.github.com https://hcaptcha.com https://*.hcaptcha.com *.algolia.net *.algolianet.com *.apachecon.com *.communityovercode.org 'unsafe-inline' 'unsafe-eval'; frame-src *; frame-ancestors 'self' *.google.com; worker-src 'self' data: blob:; img-src 'self' blob: data: https:; font-src 'self' data: blob:; object-src 'none'"

src/.vuepress/styles/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,8 @@ div[class*='language-'] pre code {
190190

191191
.vp-project-home .vp-hero-info-wrapper:not(.fullscreen) .vp-hero-info {
192192
max-width: 100% !important;
193+
}
194+
.vp-back-to-top-button {
195+
transform: none !important;
196+
bottom: 4.5rem;
193197
}

0 commit comments

Comments
 (0)