mirror of
https://github.com/wahyd4/links.git
synced 2026-08-08 21:04:53 +10:00
- Add jbot Django app (jbot/__init__.py, apps.py, urls.py, api_urls.py) - Python backend (jbot/views.py): TTS 2.0, ASR 1.0 BigASR, LLM/memory via OpenRouter - React SPA frontend at /jbot/ (static_src/jbot/): RobotFace, ChatPanel, expressions, voices, push-to-talk, history, memory, settings pages - Vite entry jbot: static_src/jbot/main.jsx → dist/jbot.js + dist/jbot.css - react-router-dom added; BrowserRouter basename=/jbot for SPA routing - core/settings.py: added jbot to INSTALLED_APPS - core/urls.py: /jbot/ + /api/jbot/ URL includes - pyproject.toml: websocket-client>=1.9.0 for BigASR binary WS protocol - Dockerfile: ffmpeg added to production apt-get for WebM→PCM audio conversion - k8s/manifest.yaml: VOLC_APP_ID, VOLC_ACCESS_TOKEN, OPENROUTER_API_KEY env vars via jbot-credentials Secret; LLM_MODEL, VOLC_TTS_VOICE, VOLC_ASR_RESOURCE defaults Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 lines
9.8 KiB
JavaScript
2 lines
9.8 KiB
JavaScript
import{R as A,j as e,r as n}from"./client-DS0SU7Jy.js";const T=({children:s,variant:r="default",className:t=""})=>{const c={default:"bg-gray-100 text-gray-800",link:"bg-blue-100 text-blue-800",page:"bg-green-100 text-green-800",post:"bg-purple-100 text-purple-800"};return e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${c[r]} ${t}`,children:s})},f=({children:s,className:r="",hover:t=!1})=>e.jsx("div",{className:`bg-white rounded-lg shadow-sm border border-gray-200 ${t?"hover:shadow-md transition-shadow duration-200":""} ${r}`,children:s}),D=({className:s="",...r})=>e.jsx("input",{className:`flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:cursor-not-allowed disabled:opacity-50 ${s}`,...r}),F=({children:s,className:r="",...t})=>e.jsx("select",{className:`flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:cursor-not-allowed disabled:opacity-50 ${r}`,...t,children:s}),y=({children:s,variant:r="default",className:t="",...c})=>{const o={default:"bg-blue-600 text-white hover:bg-blue-700",outline:"border-2 border-gray-300 bg-white hover:bg-gray-50",ghost:"hover:bg-gray-100"};return e.jsx("button",{className:`inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium ring-offset-white transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${o[r]} ${t}`,...c,children:s})},N=({className:s=""})=>e.jsx("div",{className:`shimmer rounded ${s}`}),U=({result:s})=>{const r={link:"fa-link",page:"fa-file-alt",post:"fa-newspaper"},t=c=>new Date(c).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return e.jsx(f,{hover:!0,className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${s.type==="link"?"bg-blue-100 text-blue-600":s.type==="page"?"bg-green-100 text-green-600":"bg-purple-100 text-purple-600"}`,children:e.jsx("i",{className:`fas ${r[s.type]}`})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("a",{href:s.type==="link"?s.url:s.detail_url||s.url,className:"text-lg font-semibold text-gray-900 hover:text-blue-600 transition-colors truncate",target:s.type==="link"?"_blank":"_self",rel:s.type==="link"?"noopener noreferrer":"",children:s.title}),e.jsx(T,{variant:s.type,children:s.type})]}),s.type==="link"&&s.original_url&&e.jsxs("a",{href:s.original_url,className:"text-sm text-gray-600 hover:text-gray-900 truncate block mb-2",target:"_blank",rel:"noopener noreferrer",children:[e.jsx("i",{className:"fas fa-external-link-alt mr-1"}),s.original_url]}),(s.description||s.summary)&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-2",children:s.description||s.summary}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[e.jsxs("span",{children:[e.jsx("i",{className:"fas fa-calendar mr-1"}),t(s.created_at)]}),s.click_count!==void 0&&e.jsxs("span",{children:[e.jsx("i",{className:"fas fa-mouse-pointer mr-1"}),s.click_count," clicks"]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:s.tags.map(c=>e.jsxs(T,{variant:"default",className:"text-xs",children:[e.jsx("i",{className:"fas fa-tag mr-1"}),c.name]},c.id))})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("a",{href:s.type==="link"?`/link/${s.id}/edit/`:s.type==="page"?`/ui/pages/${s.id}/edit/`:`/ui/posts/${s.id}/edit/`,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Edit",children:e.jsx("i",{className:"fas fa-edit"})})})]})})},B=()=>{const[s,r]=n.useState(""),[t,c]=n.useState(""),[o,$]=n.useState("relevance"),[p,I]=n.useState(!1),[v,g]=n.useState([]),[x,P]=n.useState(!1),[u,_]=n.useState(0),[d,C]=n.useState(1),[j,w]=n.useState(null),R=20,h=n.useCallback(async(a,i,l,b)=>{if(!a.trim()){g([]),_(0);return}P(!0),w(null);try{const E=new URLSearchParams({q:a,type:i,sort:l,page:b,per_page:R}),L=await fetch(`${p?"/search/api/vector/":"/search/api/v2/"}?${E}`),S=await L.json();L.ok?(g(S.results),_(S.total)):(w(S.error||"Search failed"),g([]))}catch{w("Network error. Please try again."),g([])}finally{P(!1)}},[p]),q=n.useCallback(a=>{a.preventDefault(),C(1),h(s,t,o,1)},[s,t,o,h]);n.useEffect(()=>{const a=new URLSearchParams(window.location.search),i=a.get("q")||"",l=a.get("type")||"",b=a.get("sort")||"relevance";r(i),c(l),$(b),i&&h(i,l,b,1)},[h]),n.useEffect(()=>{if(s){const a=new URLSearchParams({q:s,...t&&{type:t},...o!=="relevance"&&{sort:o}});window.history.replaceState({},"",`?${a}`)}},[s,t,o]);const k=a=>{C(a),h(s,t,o,a),window.scrollTo({top:0,behavior:"smooth"})},m=Math.ceil(u/R);return e.jsx("div",{className:"min-h-screen py-8 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsx("a",{href:"/",className:"inline-block hover:opacity-80 transition-opacity",children:e.jsxs("h1",{className:"text-4xl font-bold text-gray-900 mb-2 flex items-center justify-center gap-3",children:[e.jsx("i",{className:"fas fa-search text-blue-600"}),"Advanced Search"]})}),e.jsx("p",{className:"text-gray-600",children:"Search through all Links, Pages, and Posts"})]}),e.jsx(f,{className:"p-6 mb-8 glass",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Search Query"}),e.jsxs("div",{className:"relative",children:[e.jsx("i",{className:"fas fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),e.jsx(D,{type:"text",value:s,onChange:a=>r(a.target.value),placeholder:"Enter keywords to search...",className:"pl-10"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Filter by Type"}),e.jsxs(F,{value:t,onChange:a=>c(a.target.value),children:[e.jsx("option",{value:"",children:"All Types"}),e.jsx("option",{value:"link",children:"Links"}),e.jsx("option",{value:"page",children:"Pages"}),e.jsx("option",{value:"post",children:"Posts"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Sort By"}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"AI Vector Search"}),e.jsx("input",{type:"checkbox",checked:p,onChange:a=>I(a.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})]}),e.jsxs(F,{value:o,onChange:a=>$(a.target.value),disabled:p,children:[e.jsx("option",{value:"relevance",children:"Most Relevant"}),e.jsx("option",{value:"newest",children:"Newest First"}),e.jsx("option",{value:"oldest",children:"Oldest First"})]})]})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fas fa-spinner fa-spin mr-2"}),"Searching..."]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"fas fa-search mr-2"}),"Search"]})})]})}),s&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-4 flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:x?"Searching...":j?e.jsxs("span",{className:"text-red-600",children:[e.jsx("i",{className:"fas fa-exclamation-circle mr-2"}),j]}):e.jsxs(e.Fragment,{children:["Search results for: ",e.jsxs("span",{className:"text-blue-600",children:['"',s,'"']}),u>0&&e.jsxs("span",{className:"text-gray-500 text-sm ml-2",children:["(",u," ",u===1?"result":"results",")"]})]})})}),x&&e.jsx("div",{className:"space-y-4",children:[1,2,3].map(a=>e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(N,{className:"w-10 h-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(N,{className:"h-5 w-3/4"}),e.jsx(N,{className:"h-4 w-full"}),e.jsx(N,{className:"h-4 w-1/2"})]})]})},a))}),!x&&!j&&v.length>0&&e.jsx("div",{className:"space-y-4",children:v.map(a=>e.jsx(U,{result:a},`${a.type}-${a.id}`))}),!x&&!j&&v.length===0&&s&&e.jsxs(f,{className:"p-12 text-center",children:[e.jsx("i",{className:"fas fa-search text-6xl text-gray-300 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No results found"}),e.jsx("p",{className:"text-gray-500",children:"Try adjusting your search terms or filters"})]}),!x&&m>1&&e.jsxs("div",{className:"mt-8 flex items-center justify-center gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>k(d-1),disabled:d===1,children:[e.jsx("i",{className:"fas fa-chevron-left mr-2"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:[...Array(Math.min(5,m))].map((a,i)=>{let l;return m<=5||d<=3?l=i+1:d>=m-2?l=m-4+i:l=d-2+i,e.jsx(y,{variant:d===l?"default":"outline",onClick:()=>k(l),className:"w-10 h-10 p-0",children:l},l)})}),e.jsxs(y,{variant:"outline",onClick:()=>k(d+1),disabled:d===m,children:["Next",e.jsx("i",{className:"fas fa-chevron-right ml-2"})]})]})]}),!s&&e.jsxs(f,{className:"p-12 text-center glass",children:[e.jsx("i",{className:"fas fa-search text-6xl text-blue-200 mb-4"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 mb-2",children:"Start Searching"}),e.jsx("p",{className:"text-gray-600 max-w-md mx-auto",children:"Enter a search query to find links, pages, and posts. You can search by title, content, URL, or tags."})]})]})})},M=A.createRoot(document.getElementById("root"));M.render(e.jsx(B,{}));
|