Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Redis Command plugin #24

Closed
wants to merge 7 commits into from

2 participants

@djworth

Adding redis command summary and usage for queries like redis rpush or redis info

@rpicard

Thanks for the submission! I'll test it out and get back to you.

@rpicard

@djworth Is there any particular reason you went with the programming file format as opposed to general? If not, I think it would be best to use general for this. I also think this is a good candidate for a category, e.g. "Redis commands". What do you think?

@djworth

@rpicard No particular reason I was following port_lookup as an example. What is the difference between the programming file format and general? Is there a link or example I can look at?

I think the category "Redis commands" is much more appropriate :)

Thanks for the feedback and testing.

@rpicard

@djworth The fields are a little different between the two. Port lookup really doesn't need to use the programming format either. It's not a big deal, but if you want certain fields (e.g. categories in general or code blocks in programming) it matters.

General format: https://github.com/duckduckgo/zeroclickinfo-fathead#general-data-file-format
Programming format: https://github.com/duckduckgo/zeroclickinfo-fathead#programming-data-file-format

Check out the RFC plugin for a good general format example with categories. If you have any trouble let me know.

@rpicard

@djworth This is live now. Thanks for working with us!

https://duckduckgo.com/?q=redis+sort

@rpicard rpicard closed this
@djworth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  redis_commands/.gitignore
@@ -0,0 +1,2 @@
+output.txt
+download
View
8 redis_commands/README.txt
@@ -0,0 +1,8 @@
+Dependencies
+
+# Freebsd
+cd /usr/ports/devel/py-lxml && make && make install
+
+# Ubuntu
+sudo apt-get -y install python-lxml
+
View
3  redis_commands/fetch.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+mkdir -p download
+wget "http://redis.io/commands" -O download/raw.dat
View
15 redis_commands/meta.txt
@@ -0,0 +1,15 @@
+# This is the name of the source as people would refer to it, e.g. Wikipedia or PerlDoc
+Name: Redis
+
+# This is the base domain where the source pages are located.
+Domain: redis.io
+
+# This is what gets put in quotes next to the source
+# It can be blank if it is a source with completely general info spanning many types of topics like Facebook.
+Type: Redis
+
+# Whether the source is from MediaWiki (1) or not (0).
+MediaWiki: 0
+
+# Keywords uses to trigger (or prefer) the source over others.
+Keywords: redis
View
47 redis_commands/parse.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import lxml.etree, lxml.html
+import re
+
+url = "http://redis.io"
+output = "output.txt"
+
+f = open(output, "w");
+
+tree = lxml.html.parse("download/raw.dat").getroot()
+commands = tree.find_class("command")
+
+data = {}
+
+for command in commands:
+
+ for row in command.findall('a'):
+ command_url = "%s/%s" % (url, row.get('href'))
+
+ for sibling in command.itersiblings():
+ usage = ""
+
+ for command_args in command.findall('span'):
+ usage = "Usage: %s %s" % (row.text, command_args.text.replace(' ', '').replace('\n', ' ').strip())
+
+ summary = "%s<br>%s" % (sibling.text, usage)
+
+ data[command_url] = (row.text, summary)
+
+for command_url in data.keys():
+ command, summary = data[command_url]
+ summary = unicode(summary).encode("utf-8")
+
+ f.write("\t".join([str(command), # title
+ "", # namespace
+ command_url, # url
+ summary, # description
+ "", # synopsis
+ "", # details
+ "", # type
+ "" # lang
+ ])
+ )
+ f.write("\n")
+f.close()
View
2  redis_commands/parse.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+python parse.py
View
2  redis_commands/queries.txt
@@ -0,0 +1,2 @@
+redis info
+redis rpush
Something went wrong with that request. Please try again.