Jump to content

Hacker News Search


jereze

Recommended Posts

Sure. Vitorgalvao's workflow only searches from the front page of Hacker News (the latest publications), whereas mine searches the full history.

Link to comment
Share on other sites

1 hour ago, jereze said:

Please let me know the publication procedure.


Everything is covered in the pinned post.

 

At a glance, you’re missing a list of dependencies and a proper screenshot. Once those are provided I’ll proceed with the review.

Link to comment
Share on other sites

Posted (edited)

Thanks for your answer. My bad, I thought having them in the README file on Github was enough.

 

Screenshot:

 

screenshot.thumb.png.7ab7e066cb2b1864b579412dd03bfed0.png

 

Same with transparency :

screenshot.thumb.png.3a598d888e730ad411612b53d946e64e.png

 

Dependency:

 

* jq

Edited by jereze
Link to comment
Share on other sites

Almost ready to go, but your icon is under 256x256px. It needs to be at least that size. In addition, you don’t have to add an icon to the Script Filter if is uses the same as the workflow, Alfred will use it by default.

Link to comment
Share on other sites

Just noticed a problem when doing the final tests. Search for Twitter's things. Do you see how some of the items don’t have a title? That should be fixed.


Also, I have a few code suggestions:

  • You don’t need the #!/bin/bash shebang at the top. You’re already telling Alfred to use /bin/bash so it’s not doing anything.
  • Your jq message will show a dialog to the user but it could instead show the message in Alfred and make the result invalid.
  • You’re only escaping a few characters in QUERY. It would be more robust to URL encode the full text.

The following code addresses the three suggestions above. But the more pressing thing is to fix the lack of titles in some cases. Once that’s addressed the workflow can go in, I have the Gallery page done and ready.

 

if ! command -v dsfds &> /dev/null; then
  echo '{ "items": [{ "title": "jq is not installed", "subtitle": "Use Alfred’s Dependency Manager to install it", "valid": false }] }'
  exit 1
fi

QUERY="$(/usr/bin/osascript -l JavaScript -e 'function run(argv) { return encodeURIComponent(argv[0]) }' "${1}")"

curl -s "https://hn.algolia.com/api/v1/search?query=${QUERY}" | jq \
'{ "items": [.hits[] | { 
	uid: .objectID,
	title: (.title // .comment_text),
	subtitle: "\(._tags[0]) | \(.created_at[0:10]) | \(.points // 0) pt",
	arg: "https://news.ycombinator.com/item?id=\(.objectID)" }
] }'

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...