reformatting html
This commit is contained in:
parent
6fe3685f92
commit
79660f803d
7 changed files with 96 additions and 35 deletions
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module searchengine
|
||||
|
||||
go 1.23
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.9.1 // indirect
|
||||
|
|
28
images.go
28
images.go
|
@ -131,19 +131,23 @@ func handleImageSearch(w http.ResponseWriter, query, safe, lang string, page int
|
|||
}
|
||||
|
||||
data := struct {
|
||||
Results []ImageSearchResult
|
||||
Query string
|
||||
Page int
|
||||
Fetched string
|
||||
HasPrevPage bool
|
||||
HasNextPage bool
|
||||
Results []ImageSearchResult
|
||||
Query string
|
||||
Page int
|
||||
Fetched string
|
||||
LanguageOptions []LanguageOption
|
||||
CurrentLang string
|
||||
HasPrevPage bool
|
||||
HasNextPage bool
|
||||
}{
|
||||
Results: results,
|
||||
Query: query,
|
||||
Page: page,
|
||||
Fetched: fmt.Sprintf("%.2f seconds", time.Since(time.Now()).Seconds()),
|
||||
HasPrevPage: page > 1,
|
||||
HasNextPage: len(results) >= 50,
|
||||
Results: results,
|
||||
Query: query,
|
||||
Page: page,
|
||||
Fetched: fmt.Sprintf("%.2f seconds", time.Since(time.Now()).Seconds()),
|
||||
LanguageOptions: languageOptions,
|
||||
CurrentLang: lang,
|
||||
HasPrevPage: page > 1,
|
||||
HasNextPage: len(results) >= 50,
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, data)
|
||||
|
|
2
main.go
2
main.go
|
@ -108,7 +108,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
switch searchType {
|
||||
case "text":
|
||||
handleTextSearch(w, r, query, safe, lang) // Handles fetching and rendering text search results
|
||||
handleTextSearch(w, query, safe, lang) // Handles fetching and rendering text search results
|
||||
case "image":
|
||||
handleImageSearch(w, query, safe, lang, page) // Adjusted: Pass *http.Request to match the function signature
|
||||
default:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<a id="clearSearch" class="material-icons-round">close</a>
|
||||
</div>
|
||||
<div class="search-button-wrapper">
|
||||
<input type="hidden" name="p" value="1">
|
||||
<button name="t" value="text" type="submit">Search Text</button>
|
||||
<button name="t" value="image" type="submit">Search Images</button>
|
||||
</div>
|
||||
|
|
|
@ -3,21 +3,55 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Query}} - Spitfire Search</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Ocásek</h1>
|
||||
<form action="/search" method="post" class="search-form" autocomplete="off">
|
||||
<div class="search-bar">
|
||||
<input type="text" name="q" value="{{ .Query }}" autofocus id="search-input" placeholder="Type to search..." />
|
||||
<button type="submit" id="search-btn">Search</button>
|
||||
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
|
||||
<h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
|
||||
<div class="wrapper-results">
|
||||
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." />
|
||||
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="image">search</button>
|
||||
<input type="submit" class="hide" name="t" value="image" />
|
||||
</div>
|
||||
<div class="sub-search-button-wrapper">
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="text">search</button>
|
||||
<button name="t" value="text" class="clickable">Web</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="image">image</button>
|
||||
<button name="t" value="image" class="clickable search-active">Images</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="video">movie</button>
|
||||
<button name="t" value="video" class="clickable">Videos</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="reddit">forum</button>
|
||||
<button name="t" value="forum" class="clickable">Forums</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="torrent">share</button>
|
||||
<button name="t" value="torrent" class="clickable">Torrents</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="results_settings" action="/search" method="get">
|
||||
<input type="hidden" name="q" value="{{ .Query }}">
|
||||
<select class="results-settings" name="safe" id="safeSearchSelect">
|
||||
<option value="">Safe Search Off</option>
|
||||
<option value="active">Safe Search On</option>
|
||||
</select>
|
||||
<select class="results-settings" name="lang" id="languageSelect">
|
||||
{{range .LanguageOptions}}
|
||||
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<button class="results-save" type="submit">Apply settings</button>
|
||||
</form>
|
||||
<div class="search-results">
|
||||
<h1>Image Search Results</h1>
|
||||
{{ if .Results }}
|
||||
<div class="images images_viewer_hidden">
|
||||
<!-- Image Viewer Placeholder - Adapt as necessary -->
|
||||
|
|
|
@ -3,19 +3,41 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Query}} - Spitfire Search</title>
|
||||
<title>{{.Query}} - Ocásek</title>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Ocásek</h1>
|
||||
<form action="/search" method="post" class="search-form" autocomplete="off">
|
||||
<div class="search-bar">
|
||||
<input type="text" name="q" value="{{ .Query }}" autofocus id="search-input" placeholder="Type to search..." />
|
||||
<button type="submit" id="search-btn">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
<form action="/search" id="prev-next-form" class="results-search-container" method="GET" autocomplete="off">
|
||||
<h1 class="logomobile"><a class="no-decoration" href="./">Ocásek</a></h1>
|
||||
<div class="wrapper-results">
|
||||
<input type="text" name="q" value="{{ .Query }}" id="search-input" placeholder="Type to search..." />
|
||||
<button id="search-wrapper-ico" class="material-icons-round" name="t" value="text">search</button>
|
||||
<input type="submit" class="hide" name="t" value="text" />
|
||||
</div>
|
||||
<div class="sub-search-button-wrapper">
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable search-active" name="t" value="text">search</button>
|
||||
<button name="t" value="text" class="clickable search-active">Web</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="image">image</button>
|
||||
<button name="t" value="image" class="clickable">Images</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="video">movie</button>
|
||||
<button name="t" value="video" class="clickable">Videos</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="reddit">forum</button>
|
||||
<button name="t" value="forum" class="clickable">Forums</button>
|
||||
</div>
|
||||
<div class="search-container-results-btn">
|
||||
<button id="sub-search-wrapper-ico" class="material-icons-round clickable" name="t" value="torrent">share</button>
|
||||
<button name="t" value="torrent" class="clickable">Torrents</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="results_settings" action="/search" method="get">
|
||||
<input type="hidden" name="q" value="{{ .Query }}">
|
||||
<select class="results-settings" name="safe" id="safeSearchSelect">
|
||||
|
|
2
text.go
2
text.go
|
@ -74,7 +74,7 @@ func PerformTextSearch(query, safe, lang string) ([]TextSearchResult, error) {
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func handleTextSearch(w http.ResponseWriter, r *http.Request, query, safe, lang string) {
|
||||
func handleTextSearch(w http.ResponseWriter, query, safe, lang string) {
|
||||
// Perform the text search
|
||||
results, err := PerformTextSearch(query, safe, lang)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue