Searching

Given the WriteFreely issue with tag pages not being paginated, and both Google and DuckDuckGo having incomplete results when doing a “[term] site:write.house”, is native search anywhere on the horizon? It’s gotten to the point where in order to find anything on my own site I have to download an export and text-search a local copy of the archive, and then manually call up the URL in order to link old posts.

Hi @bix,

I do not know where this feature is on the horizon, but I do know that the API for a Write Freely instance works similarly to the Write.as API. So just as you can use the API to create custom search solutions with Write.as blogs, one can do so for a WriteFreely instance until a native solution is up.

So here is a little “proof of concept” example with your blog in mind. It is a rough mock up (takes a while to load, the dates are not formatted, and I just appended the slug as a title replacement) but it should give an impression of what can be created. Would be glad to share the code. Hope it helps in some way.

1 Like

Thank you, cjeller!

As someone who has used your write.as API, python 2 glitch code to search my write.as blogs, I’d like to mention, and thank you for, the following two things that I did not know how to do and these are made perfectly clear in this new code:

  1. Although I could understand and follow the write.as API code, it was not clear to me how to do WriteFreely API code and I was not able to find documentation on it. This writefreely code you made for bix completely cleared that up. As an example, the following excerpt from search.py:
def getAll(alias):
    c = writefreely.client('<enter a writefreely instance name>')

And including in .requirements.txt => writefreelyapi

Edit: Oh, I just saw your WriteFreely API code was today put on github, thanks!

  1. Your new code for bix is python 3, which is a great example of how to write glitch apps in python 3. You had previously given us some python 3 glitch code for other apps, but this now provides the way to upgrade any earlier write.as or writefreely API search code to python 3.

So thanks again!

1 Like

You are welcome @bugbuster! Glad you found the documentation.

And you got it - the WriteFreely and Write.as API code differ in how you instantiate the client. Since the API endpoints are similar, just about everything else is the same.

Here is a boiler plate WriteFreely search app (it has @OddBloke’s blog in there as a test). The code and documentation is a bit more laid out so feel free to remix it for your own use.

1 Like

Is there a remixable version of this for Write.as instead of WF?

Yep! I created a remixable version of the app here. It has my blog set up with it if you’d like to test the functionality.

@bix, the results from your blog will look different because you don’t use titles. So what I did was make a custom test version of the app here that includes your CSS and creates a 'date-preview ’ format of the search results. Feel free to remix/look at the code here.

Hm. I was trying to make it easier to use my custom CSS in this sort of thing by putting it in a github repository, but testing it on a WF blog it won’t at-import, even though I have Google fonts loaded via at-import.

Github repos are weird in that they technically do not host your CSS as a static file. This means you are unable to at-import them. However, you can enable Github pages which allows you to host the raw static file, allowing you to at-import them.

What you do is go into the settings of your repo and scroll down to Github Pages. From there make the ‘Source’ your master branch. It should then inform you that your project is now published at a Github Pages url that looks like https://bixgit.github.io/bixblog/.

Now add the file to the route so it looks like: https://bixgit.github.io/bixblog/bixblog.css. Then you should be able to at-import it.

But besides that, does the search functionality in the app work for your use case?

1 Like

Then why does github have a “raw” button that lets me call up the css file directly?

Doh, I totally overlooked that @bix. Perhaps it is there for easier copy and pasting? I don’t know why the “raw” link doesn’t work. Might be a security measure beyond my understanding.

But I tested at-importing a CSS file from a Github pages link and it worked for me. Let me know if it does the trick for you!

1 Like

Yes that works. Thanks.

Is there no way to keep the search button from launching an entirely new window? Can’t it just run and load in the window you’re in?

ETA: Never mind, I solved that issue.

But here’s a new one: it apparently won’t accept my at-import of the .css file hosted by github.

ETA: Never mind. User error.

1 Like

I’m assuming that the trick of getting a link to it in the navbar relies on custom javascript, which I can’t do until I get my domain.

Yes, getting the link into the navbar requires Custom JS. But if you go into Customize and change your Preferred URL to bix.writeas.com, you then can use Custom JS for your blog.

While you wait for your domain (or when you have it), add this to the Custom JS, putting in the placeholder Write.as post url and the search app’s url:

var a = document.querySelector('a[href="https://bix.writeas.com/search"]');
if (a) {
  a.setAttribute('href', 'https://bix-search.glitch.me/');
}
2 Likes

That’s probably a bit too many URL changes for me. I’ll just wait until next week when the domain should start getting squared away.

Haha I just figured that after I replied so no worries waiting at all!

OOC, where would I go to read up on the variables for use in the search results display?

I would look into the developer docs, specifically what values are returned when you retrieve a post. That is what I reference in the code to return posts that match a search result.

New one: why does adding a new search form to the search results template not work?

That’s a good question. Could you share the link to your Glitch project? That way we can take a look at the code and see why it’s happening.