From e64c4924f4a052f5cc45e7d631681cffdb19b62a Mon Sep 17 00:00:00 2001
From: Ben Kurtovic
- Check back later. Have you read our about page and the docs?
-
- bitshift is a search-engine optimized for source code: beyond supporting searches with the full range of ASCII
- symbols, the engine understands code, allowing users to query for metadata, like time of creation/last
- modification, programming language, and even symbols like function names and variables. Basic use boils down to
- general and advanced searches.
+ bitshift is a search-engine optimized for
+ source code: beyond supporting searches with the full range of ASCII
+ symbols, the engine understands code, allowing users to query
+ for metadata, like time of creation/last modification, programming
+ language, and even symbols like function names and variables. Basic use
+ boils down to general and advanced searches.
- To perform a "general search," simply place your cursor in the search bar on our home page and begin
- entering text; when you stop typing for a short period of time, we'll automatically execute the query for you.
- As you scroll down the results page, new codelets will be seamlessly downloaded from our server and
- appended to the end.
+ To perform a "general search," simply place your cursor in the
+ search bar on our home page and begin entering text; when you
+ stop typing for a short period of time, we'll automatically
+ execute the query for you. As you scroll down the page, new
+ codelets, or results, will be seamlessly downloaded from our
+ server and appended to the end.
- General searches, though, are limited. To allow users to make the best of our engine, we created an advanced
- search form that allows the creation of complex queries with the following specifiers:
+ General searches, though, are limited. To allow users to make the
+ best of our engine, we created an advanced search form that
+ allows the creation of complex queries with the following
+ specifiers:
- Each of the search fields allows for numerous values; just separate them with spaces. If you'd like
- to search for a multi-word, space-delimited string, on the other hand, enclose it in double quotes.
+ Each of the search fields allows for numerous values; just
+ separate them with spaces. If you'd like to search for a
+ multi-word, space-delimited string, on the other hand,
+ enclose it in double quotes.
- A query for foo bar will search for occurrences of both "foo" and "bar", while "foo bar"
- will search for occurrences of "foo bar".
+ A query for foo bar will search
+ for occurrences of both "foo" and
+ "bar", while
+ "foo bar" will search for
+ occurrences of "foo bar".
- Search groups facilitate even more robust queries: they're like a bunch of individual searches
- grouped into one. A user searching for occurrenes of symbol "curses" in the
- language "Python", and "ncurses" in "C", won't get away with: symbols: "curses ncurses" and
- languages: "Python C". The engine might return results "curses" in "C" and "ncurses" in
- "Python"!
-
- To work around that, you can use two search groups: one for "curses" in
- "Python", and another for "curses" in "C". bitshift will return the union of both sets of search results.
+ Search groups facilitate even more robust queries: they're
+ like a bunch of individual searches grouped into one. A
+ user searching for occurrenes of symbol
+ "curses" in the language
+ "Python", and
+ "ncurses" in
+ "C", won't get away with:
+ "symbols:curses ncurses" and
+ "languages:Python C". The engine
+ might return results "curses" in
+ "C" and
+ "ncurses" in
+ "Python"!
+
+ To work around that, you can use two search groups: one for
+ "curses" in
+ "Python", and another for
+ "curses" in
+ "C".
+ bitshift will return the union
+ of both sets of search results.
'
-
-var testCodelet = {
- 'url': 'https://github.com/earwig/bitshift/blob/develop/app.py',
- 'name': 'app.py',
- 'lang': 'python',
- 'created': 'May 10, 2014 aaaaaaaaaa',
- 'modified': '2 days ago',
- 'origin': ['GitHub', 'https://github.com', ''],
- 'authors': ['sevko', 'earwig', 'another author', 'a'],
- 'code': codeExample
-};
-
// Enable infinite scrolling down the results page.
$(window).scroll(function() {
var searchField = $("div#search-field");
@@ -396,7 +382,8 @@ function nextSymbolMatch() {
function queryServer(){
var queryUrl = document.URL + "search.json?" + $.param({
"q" : searchBar.value,
- "p" : searchResultsPage++
+ "p" : searchResultsPage++,
+ "hl": 1
});
var results = $.Deferred();
diff --git a/static/sass/developers.sass b/static/sass/developers.sass
deleted file mode 100644
index 419dc3e..0000000
--- a/static/sass/developers.sass
+++ /dev/null
@@ -1,7 +0,0 @@
-@import variables
-
-a
- text-decoration: none
-
-h1
- color: $baseColor1
diff --git a/static/sass/docs.sass b/static/sass/docs.sass
index 6d23e32..4d851df 100644
--- a/static/sass/docs.sass
+++ b/static/sass/docs.sass
@@ -21,17 +21,17 @@ ul
margin-bottom: 2%
span
- code
+ &.code
background-color: $baseColor3 * 1.2
font-family: monospace
padding: 5px
- string
+ &.string
color: $baseColor1
font-family: monospace
font-size: 1.1em
- title
+ &.title
color: $baseColor1
font-weight: bold
diff --git a/static/sitemap.xml b/static/sitemap.xml
index ff8ccbf..24adafe 100644
--- a/static/sitemap.xml
+++ b/static/sitemap.xml
@@ -4,13 +4,13 @@
1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40
"""\nModule to contain all the project's Flask server plumbing.\n"""\n\nfrom flask import Flask\nfrom flask import render_template, session\n\nfrom bitshift import assets\n# from bitshift.database import Database\n# from bitshift.query import parse_query\n\napp = Flask(__name__)\napp.config.from_object("bitshift.config")\n\napp_env = app.jinja_env\napp_env.line_statement_prefix = "="\napp_env.globals.update(assets=assets)\n\n# database = Database()\n\n@app.route("/")\ndef index():\n return render_template("index.html")\n\n@app.route("/search/<query>")\ndef search(query):\n # tree = parse_query(query)\n # database.search(tree)\n pass\n\n@app.route("/about")\ndef about():\n return render_template("about.html")\n\n@app.route("/developers")\ndef developers():\n return render_template("developers.html")\n\nif __name__ == "__main__":\n app.run(deaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabug=True)\n
Page under construction
- » Usage
general search
advanced search
@@ -115,11 +145,145 @@
search fields
search groups
+ bitshift provides an API through GET + requests to + /search.json. +
++ /search.json returns a JSON-encoded + dictionary. If there was an error, it will contain a single key, + "error", whose value will contain a + human-readable description of the error. Otherwise, there will be two + keys: "count", storing the number of results, + and "results", storing a list of codelets. + Each codelet is a dictionary with the following key–value pairs: +
++ The following example Python 2 code searches for a given Python + function definition and prints the URL of the first result: +
+
+
+
+ 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19+ |
+
+
+
+ #!/usr/bin/env python + + from json import loads + from sys import argv + from urllib import urlencode + from urllib2 import urlopen + + def get_function(name): + params = {"q": "lang:python and func:def:%s" % name} + request = urlopen("http://bitshift.it/search.json?" + urlencode(params)) + res = loads(request.read())["results"] + if res: + print "%s: %s" % (name, res[0]["url"]) + else: + print "%s not found." % name + + if __name__ == "__main__": + if len(argv) == 2: + get_function(argv[1]) ++ |
+
- bitshift is (gasp) open-source! The project is hosted on - GitHub; feel free to file an issue or submit a pull request! + bitshift is (gasp) + open-source! The project is hosted on + GitHub; feel free to + file an issue or submit a pull request.