LukeSmithxyz / based.cooking

A simple culinary website.
The Unlicense
2.2k stars 549 forks source link

Search? #150

Closed marekkowalczyk closed 3 years ago

marekkowalczyk commented 3 years ago

Let's have a search box, in due time.

surfaceflinger commented 3 years ago

You can just use ctrl+f in browser. I guess some simple php for searching could be useful if in the future categories on separate pages would be introduced.

Goblin80 commented 3 years ago

153

Godje commented 3 years ago

@Morelcia I assume the point is to not have a serverside preprocessor. Currently the side is literally assembled through a shell script. A search box with a JS filter function that has an array of pages would do just fine, and would be serverside. It simple enough and light enough to not need to be cached (which means we could just put it in the head of the script).

surfaceflinger commented 3 years ago

Afaik point is to be as lightweight as possible clientside and to work without js. +serverside js abominations definitely aren't lightweight unless you meant something else.

Godje commented 3 years ago

@Morelcia definitely not serverside. Client side small amount of javascript (6 to 10 loc), inside the <script> tag. I can make a PR of something like that tomorrow, but the general sensus against Javascript here is pretty obvious, so I am pinging the community about how much is not "a lot".

Godje commented 3 years ago

Since the amount of script I want to add is miniscule, it has no need to exist in a separate Network call to import the Javascript. So we can put it in the <head> tag, or at the bottom of HTML and forget it. When you don't import the stuff in a separate file, it doesn't get cached. But since the amount of code is so small, there is no need for caching.

Goblin80 commented 3 years ago

@Godje I see you point, and if you ask me i have no problem with minimal JS. but i don't think luke and the community will approve that. he was pretty clear about a no JS policy.

marekkowalczyk commented 3 years ago

How about an alphabetized static index page of user-marked [[keywords]]?

Something along the lines of

grep -HE \\[\\[.+\\]\\] *.md | sed -e 's/\[//g' -e 's/\]//g' -e 's/\.md//' | awk -F ':' '{print "<a href=\"" $1 ".html\">" $2 "</a>"}' | sort | uniq -u

(not actually usable as is because it doesn't collect occurrences of a keyword in different files into one entry, but you get the idea).

adeptflax commented 3 years ago

How about JavaScript on the server-side? http://www.cgi-node.org/. PHP is cringe.

surfaceflinger commented 3 years ago

Why would someone run backend in language which runtime takes 500MB ram in idle? unironically php>nodejs

adeptflax commented 3 years ago

@Morelcia lol no it doesn't

adeptflax commented 3 years ago

ok serious this time, the most efficient thing would be a c++ nginx plugin.

0x0000F1 commented 3 years ago

ctrl+f should be more than enough

adeptflax commented 3 years ago

the laziest way would probably be bash-cgi script.

dko1905 commented 3 years ago

ctrl+f should be more than enough

The chad way to search is to use the inbuilt search.

adeptflax commented 3 years ago

actually making a duckduckgo search form would be even easier

adeptflax commented 3 years ago
<form action="https://duckduckgo.com/">
  <input type="text" name="q">
  <input type="hidden" name="sites" value="based.cooking">
  <button type="submit">Search</button>
</form>
adeptflax commented 3 years ago

what you guys, think? I'll make a PR If you guys think it's a good idea. Would between the tags and the "Recipe" header be a good place to put it?

vasilenko93 commented 3 years ago

Cannot see anything wrong with Ctrl-f, or / if you are using Vim keybindings. This might become a problem with thousands of recipes, maybe, but right now its not a problem at all.

Godje commented 3 years ago

@adeptflax I just tried what you did by just adding it in the devtools, and it genuinely works. This way we are not increasing the size of the website on the VPS, and we are increasing the search ratings for the based.cooking URL lol :)

LukeSmithxyz commented 3 years ago

Ctrl-f is more than sufficient now while all recipes are still on the main page.

If the site gets large enough, we will get a php search or something of the sort.