Download index.html from stonarini/grepac: direct link, hf CLI and curl.
- Browser
- Download file 7.83 kB
-
https://huggingface.co/spaces/stonarini/grepac/resolve/main/index.html
- Command line
-
hf download hf://spaces/stonarini/grepac/index.html
-
curl -L -o index.html https://huggingface.co/spaces/stonarini/grepac/resolve/main/index.html
7.83 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>grePAC</title> | |
| <meta name="description" content="Search the EU Common Agricultural Policy regulations 2021/2115 and 2021/2116. Results are the articles themselves."> | |
| <style> | |
| :root { | |
| --desk: #e7e5df; --paper: #fffefb; --ink: #1f1f1d; --muted: #6b6a65; --rule: #d9d6ce; --mark: #1f1f1d; | |
| --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif; | |
| } | |
| @media (prefers-color-scheme: dark) { | |
| :root { --desk: #111110; --paper: #1d1d1b; --ink: #e9e7e1; --muted: #9c9a93; --rule: #3a3935; --mark: #ffffff; } | |
| } | |
| * { box-sizing: border-box; } | |
| html { background: var(--desk); } | |
| body { margin: 0; padding: 32px 16px; font: 17px/1.6 var(--serif); color: var(--ink); background: var(--desk); } | |
| .sheet { max-width: 210mm; min-height: 297mm; margin: 0 auto; padding: 22mm 20mm; background: var(--paper); | |
| box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06); display: flex; flex-direction: column; } | |
| @media (max-width: 640px) { body { padding: 0; } .sheet { padding: 28px 16px; min-height: 100vh; box-shadow: none; } | |
| p.text { text-align: left; } } | |
| h1 { font-size: 1.9rem; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; } | |
| .sub { margin: 0 0 28px; color: var(--muted); } | |
| form { margin: 0 0 8px; } | |
| input { width: 100%; font: inherit; color: var(--ink); background: transparent; padding: 8px 0; | |
| border: none; border-bottom: 1px solid var(--ink); border-radius: 0; } | |
| input:focus { outline: none; border-bottom-width: 2px; padding-bottom: 7px; } | |
| input::-webkit-search-cancel-button { -webkit-appearance: none; } | |
| input::placeholder { color: var(--muted); font-style: italic; } | |
| .status { color: var(--muted); font-style: italic; margin: 16px 0 0; } | |
| .status:empty { margin: 0; } | |
| section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--rule); } | |
| section:first-child { border-top: none; padding-top: 0; } | |
| h3 { font-size: 1.05rem; margin: 0 0 8px; font-weight: 600; } | |
| h3 small { font-weight: 400; color: var(--muted); font-size: .9rem; } | |
| p.text { margin: 0; white-space: pre-wrap; text-align: justify; hyphens: auto; } | |
| p.text b { color: var(--mark); } | |
| p.lead { margin: 0 0 6px; white-space: pre-wrap; color: var(--muted); } | |
| .source { margin: 8px 0 0; font-size: .85rem; } | |
| a { color: inherit; } | |
| .helpful { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--rule); } | |
| .helpful button { font: inherit; color: var(--ink); background: none; border: 1px solid var(--ink); | |
| padding: 2px 14px; margin-left: 8px; cursor: pointer; } | |
| .helpful button:hover, .helpful button:focus-visible { background: var(--ink); color: var(--paper); outline: none; } | |
| footer { margin-top: auto; padding-top: 40px; font-size: .8rem; color: var(--muted); } | |
| [hidden] { display: none ; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="sheet"> | |
| <header> | |
| <h1>grePAC</h1> | |
| <p class="sub">Search the EU farm law: Regulations (EU) 2021/2115 and 2021/2116 of the Common Agricultural Policy. | |
| You get the articles as written, not a summary.</p> | |
| </header> | |
| <form id="form" role="search"> | |
| <input id="q" type="search" maxlength="500" autocomplete="off" autofocus aria-label="Your question" | |
| placeholder="Ask a question, or type an article such as art. 31 2115"> | |
| </form> | |
| <p class="status" id="status" role="status" aria-live="polite"></p> | |
| <div id="results"></div> | |
| <div class="helpful" id="helpful" hidden> | |
| Was it helpful? <button type="button" data-v="1">Yes</button><button type="button" data-v="0">No</button> | |
| </div> | |
| <footer> | |
| <p>Not legal advice. Check the official text on EUR-Lex. | |
| Searches, their results and your yes/no answers are saved to improve the search; IP addresses are not saved. | |
| Articles only, annexes not yet included. <span id="versions"></span> | |
| Source: <a href="https://eur-lex.europa.eu" rel="noopener">EUR-Lex</a>, © European Union. | |
| <a href="https://github.com/stonarini/grepac" rel="noopener">Code</a>.</p> | |
| </footer> | |
| </div> | |
| <script> | |
| // API address. For local testing: ?api=http://127.0.0.1:8000 | |
| const API = new URLSearchParams(location.search).get("api") || "https://grepac.dost.pt"; | |
| const REG = { "2115": "Regulation (EU) 2021/2115", "2116": "Regulation (EU) 2021/2116" }; | |
| const $ = (id) => document.getElementById(id); | |
| let current = null; // query_id of the results on screen | |
| function el(tag, props, ...children) { | |
| const n = Object.assign(document.createElement(tag), props || {}); | |
| n.append(...children.filter((c) => c != null)); | |
| return n; | |
| } | |
| async function api(path, options) { | |
| const res = await fetch(API + path, options); | |
| if (res.status === 204) return null; | |
| const body = await res.json().catch(() => ({})); | |
| if (!res.ok) throw Object.assign(new Error(body.error || "HTTP " + res.status), { status: res.status }); | |
| return body; | |
| } | |
| function textWithMatch(text, span) { | |
| const p = el("p", { className: "text" }); | |
| if (!span) { p.textContent = text; return p; } | |
| p.append(text.slice(0, span[0]), el("b", { textContent: text.slice(span[0], span[1]) }), text.slice(span[1])); | |
| return p; | |
| } | |
| function result(r) { | |
| const ref = "Article " + r.article + (r.paragraph ? "(" + r.paragraph + ")" : ""); | |
| return el("section", {}, | |
| el("h3", {}, ref + ", " + r.article_title + " ", el("small", { textContent: REG[r.reg] || r.reg })), | |
| r.lead_in ? el("p", { className: "lead", textContent: r.lead_in }) : null, | |
| textWithMatch(r.text, r.match), | |
| el("p", { className: "source" }, el("a", { href: r.url, target: "_blank", rel: "noopener", textContent: "Open on EUR-Lex" }))); | |
| } | |
| async function search(q) { | |
| q = q.trim(); | |
| if (!q) return; | |
| history.replaceState(null, "", "?" + new URLSearchParams({ q, ...(new URLSearchParams(location.search).get("api") && { api: API }) })); | |
| $("status").textContent = "Searching…"; | |
| $("results").replaceChildren(); | |
| $("helpful").hidden = true; | |
| current = null; | |
| try { | |
| const d = await api("/api/search?" + new URLSearchParams({ q, k: "5" })); | |
| if (!d.results.length) { $("status").textContent = "Nothing found."; return; } | |
| $("status").textContent = d.mode === "exact" | |
| ? (d.ambiguous_regulation ? "This article number exists in both regulations. Add 2115 or 2116 to choose one." : "") | |
| : ""; | |
| $("results").replaceChildren(...d.results.map(result)); | |
| if (d.versions) $("versions").textContent = | |
| "Consolidated versions: 2021/2115 of " + d.versions["2115"] + ", 2021/2116 of " + d.versions["2116"] + "."; | |
| current = d.query_id; | |
| resetHelpful(); | |
| } catch (e) { | |
| $("status").textContent = e.status ? e.message : "The search is offline at the moment. Please try again later."; | |
| } | |
| } | |
| function resetHelpful() { | |
| const box = $("helpful"); | |
| box.replaceChildren("Was it helpful? ", | |
| ...[["Yes", true], ["No", false]].map(([label, v]) => { | |
| const b = el("button", { type: "button", textContent: label }); | |
| b.onclick = () => { | |
| const id = current; | |
| box.replaceChildren("Thank you."); | |
| api("/api/feedback", { method: "POST", headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ query_id: id, helpful: v }) }).catch(() => {}); | |
| }; | |
| return b; | |
| })); | |
| box.hidden = false; | |
| } | |
| $("form").addEventListener("submit", (e) => { e.preventDefault(); search($("q").value); }); | |
| const start = new URLSearchParams(location.search).get("q"); | |
| if (start) { $("q").value = start; search(start); } | |
| else api("/api/health").catch(() => { $("status").textContent = "The search is offline at the moment. Please try again later."; }); | |
| </script> | |
| </body> | |
| </html> | |