Compare commits
57 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d6386e74a | |||
a93b7519de | |||
5e2c37164b | |||
829e9c4263 | |||
283991017c | |||
653af18f24 | |||
fae184f1f3 | |||
d40bb3557f | |||
a848f3ec3e | |||
50d27a915a | |||
1b950b7790 | |||
04d4195668 | |||
d0fe7aa799 | |||
acc28aab44 | |||
adc2666a9b | |||
581f0a67ed | |||
0b96061bc5 | |||
c7acdea889 | |||
4eabd4536e | |||
78276c14d9 | |||
68f90d383f | |||
202643b85e | |||
dc9ac74d68 | |||
36cc94a854 | |||
740e757bcd | |||
bf6afe39c6 | |||
54c09ce80b | |||
1407178f39 | |||
2bf9abfd6f | |||
8328f96f76 | |||
d5a9fe85af | |||
f8d2156d85 | |||
a753ba4963 | |||
8cca4b2c8d | |||
69339abe24 | |||
8d2718d783 | |||
8912b945fe | |||
ddceb16a2c | |||
f769d18b4e | |||
34a889479a | |||
a074e6c0e7 | |||
918c9d583f | |||
6cd505087b | |||
ee9b3bb811 | |||
8a4e20b71c | |||
64d3ce4a9b | |||
5e9b584d26 | |||
b03a42d261 | |||
bd4f4da8dc | |||
23743773a6 | |||
b7d2a8c960 | |||
1f4b43163a | |||
f80ccc2520 | |||
c2eae4f521 | |||
c758ca7a6c | |||
3cf142465a | |||
bfd351c990 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,8 +1,8 @@
|
|||||||
|
config_*
|
||||||
vp
|
vp
|
||||||
credentials.json
|
credentials.json
|
||||||
drive*.json
|
drive*.json
|
||||||
*.pyc
|
*.pyc
|
||||||
config.py
|
|
||||||
out/
|
out/
|
||||||
search_index/
|
search_index/
|
||||||
venv/
|
venv/
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "mkdocs-material"]
|
||||||
|
path = mkdocs-material
|
||||||
|
url = https://git.charlesreid1.com/charlesreid1/mkdocs-material.git
|
84
Readme.md
84
Readme.md
@@ -1,4 +1,4 @@
|
|||||||
# centillion
|
# The Centillion
|
||||||
|
|
||||||
**the centillion**: a pan-github-markdown-issues-google-docs search engine.
|
**the centillion**: a pan-github-markdown-issues-google-docs search engine.
|
||||||
|
|
||||||
@@ -6,62 +6,70 @@
|
|||||||
|
|
||||||
the centillion is 3.03 log-times better than the googol.
|
the centillion is 3.03 log-times better than the googol.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
## what is it
|
## what is it
|
||||||
|
|
||||||
The centillion is a search engine built using [whoosh](#),
|
The centillion is a search engine built using [whoosh](https://whoosh.readthedocs.io/en/latest/intro.html),
|
||||||
a Python library for building search engines.
|
a Python library for building search engines.
|
||||||
|
|
||||||
We define the types of documents the centillion should index,
|
We define the types of documents the centillion should index,
|
||||||
and how, using what fields. The centillion then builds and
|
what info and how. The centillion then builds and
|
||||||
updates a search index.
|
updates a search index. That's all done in `centillion_search.py`.
|
||||||
|
|
||||||
The centillion also provides a simple web frontend for running
|
The centillion also provides a simple web frontend for running
|
||||||
queries against the search index.
|
queries against the search index. That's done using a Flask server
|
||||||
|
defined in `centillion.py`.
|
||||||
|
|
||||||
The centillion keeps it simple.
|
The centillion keeps it simple.
|
||||||
|
|
||||||
|
|
||||||
## work that is done
|
## quickstart (with Github auth)
|
||||||
|
|
||||||
See [Workdone.md](Workdone.md)
|
Start by creating a Github OAuth application.
|
||||||
|
Get the public and private application key
|
||||||
|
(client token and client secret token)
|
||||||
|
from the Github application's page.
|
||||||
|
|
||||||
|
When you create the application, set the callback
|
||||||
|
URL to `/login/github/authorized`, as in:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://<url>/login/github/authorized
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit the Flask configuration `config_flask.py`
|
||||||
|
and set the public and private application keys.
|
||||||
|
|
||||||
|
Now run centillion:
|
||||||
|
|
||||||
|
```
|
||||||
|
python centillion.py
|
||||||
|
```
|
||||||
|
|
||||||
|
or if you used http instead of https:
|
||||||
|
|
||||||
|
```
|
||||||
|
OAUTHLIB_INSECURE_TRANSPORT="true" python centillion.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This will start a Flask server, and you can view the minimal search engine
|
||||||
|
interface in your browser at `http://<ip>:5000`.
|
||||||
|
|
||||||
|
|
||||||
## work that is being done
|
## troubleshooting
|
||||||
|
|
||||||
See [Workinprogress.md](Workinprogress.md) for details about
|
If you are having problems with your callback URL being treated
|
||||||
route and function layout. Summary below.
|
as HTTP by Github, even though there is an HTTPS address, and
|
||||||
|
everything else seems fine, try deleting the Github OAuth app
|
||||||
### code organization
|
and creating a new one.
|
||||||
|
|
||||||
centillion app routes:
|
|
||||||
|
|
||||||
- home
|
|
||||||
- if not logged in, landing page
|
|
||||||
- if logged in, redirect to search
|
|
||||||
- search
|
|
||||||
- main_index_update
|
|
||||||
- update main index, all docs period
|
|
||||||
|
|
||||||
|
|
||||||
centillion Search functions:
|
## more info
|
||||||
|
|
||||||
- open_index creates the schema
|
For more info see the documentation: <https://charlesreid1.github.io/centillion>
|
||||||
|
|
||||||
- add_issue, add_md, add_document have three diff method sigs and add diff types
|
|
||||||
of documents to the search index
|
|
||||||
|
|
||||||
- update_all_issues or update_all_md or update_all_documents iterates over items
|
|
||||||
and determines whether each item needs to be updated in the search index
|
|
||||||
|
|
||||||
- update_main_index - update the entire search index
|
|
||||||
- calls all three update_all methods
|
|
||||||
|
|
||||||
- create_search_results - package things up for jinja
|
|
||||||
|
|
||||||
- search - run the query, pass results to the jinja-packager
|
|
||||||
|
|
||||||
|
|
||||||
## work that is planned
|
|
||||||
|
|
||||||
See [Workplanned.md](Workplanned.md)
|
|
||||||
|
|
||||||
|
47
Todo.md
Normal file
47
Todo.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# todo
|
||||||
|
|
||||||
|
Main task:
|
||||||
|
- hashing and caching
|
||||||
|
- <s>first, working out the logic of how we group items into sets
|
||||||
|
- needs to be deleted
|
||||||
|
- needs to be updated
|
||||||
|
- needs to be added
|
||||||
|
- for docs, issues, and comments</s>
|
||||||
|
- second, when we add or update an item, need to:
|
||||||
|
- go through the motions, download file, extract text
|
||||||
|
- check for existing indexed doc with that id
|
||||||
|
- check if existing indexed doc has same hash
|
||||||
|
- if so, skip
|
||||||
|
- otherwise, delete and re-index
|
||||||
|
|
||||||
|
Other bugs:
|
||||||
|
- Some github issues have no title (?)
|
||||||
|
- <s>Need to combine issues with comments</s>
|
||||||
|
- Not able to index markdown files _in a repo_
|
||||||
|
- (Longer term) update main index vs update diff index
|
||||||
|
|
||||||
|
Needs:
|
||||||
|
- <s>control panel</s>
|
||||||
|
|
||||||
|
Thursday product:
|
||||||
|
- Everything re-indexed nightly
|
||||||
|
- Search engine built on all documents in Google Drive, all issues, markdown files
|
||||||
|
- Using pandoc to extract Google Drive document contents
|
||||||
|
- BRIEF quickstart documentation
|
||||||
|
|
||||||
|
Future:
|
||||||
|
- Future plans to improve - plugins, improving matching
|
||||||
|
- Subdomain plans
|
||||||
|
- Folksonomy tagging and integration plans
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config options for plugins
|
||||||
|
conditional blocks with import github inside
|
||||||
|
complicated tho - better to have components split off
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,106 +0,0 @@
|
|||||||
# Components
|
|
||||||
|
|
||||||
The components of centillion are as follows:
|
|
||||||
- Flask application, which creates a Search object and uses it to search index
|
|
||||||
- Search object, which allows you to create/update/search an index
|
|
||||||
|
|
||||||
## Routes layout
|
|
||||||
|
|
||||||
Current application routes are as follows:
|
|
||||||
|
|
||||||
- home -> search
|
|
||||||
- search
|
|
||||||
- update_index
|
|
||||||
|
|
||||||
Ideal application routes (using github flask dance oauth):
|
|
||||||
|
|
||||||
- home
|
|
||||||
- if not logged in, landing page
|
|
||||||
- if logged in, redirect to search
|
|
||||||
- search
|
|
||||||
- main_index_update
|
|
||||||
- update main index, all docs period
|
|
||||||
- delta_index_update
|
|
||||||
- updates delta index, docs that have changed since last main index
|
|
||||||
|
|
||||||
There should be one route to update the main index
|
|
||||||
|
|
||||||
There should be another route to update the delta index
|
|
||||||
|
|
||||||
These should go off and call the update index methods
|
|
||||||
for each respective type of document/collection.
|
|
||||||
For example, if I call `main_index_update` route it should
|
|
||||||
|
|
||||||
- call `main_index_update` for all github issues
|
|
||||||
- call `main_index_update` for folder of markdown docs
|
|
||||||
- call `main_index_update` for google drive folder
|
|
||||||
|
|
||||||
These are all members of the Search class
|
|
||||||
|
|
||||||
## Functions layout
|
|
||||||
|
|
||||||
Functions of the entire search app:
|
|
||||||
- create a search index
|
|
||||||
- load a search index
|
|
||||||
- call the search() method on the index
|
|
||||||
- update the search index
|
|
||||||
|
|
||||||
The first and last, creating and updating the search index,
|
|
||||||
are of greatest interest.
|
|
||||||
|
|
||||||
The Schema affects everything so it is hard to separate
|
|
||||||
functionality into a main Search class shared by many.
|
|
||||||
(Avoid inheritance/classes if possible.)
|
|
||||||
|
|
||||||
current Search:
|
|
||||||
- open_index creates the schema
|
|
||||||
- add_issue or add_document adds an item to the index
|
|
||||||
- add_all_issues or add_all_documents iterates over items and adds them to index
|
|
||||||
- update_index_incremental - update the search index
|
|
||||||
- create_search_results - package things up for jinja
|
|
||||||
- search - run the query, pass results to the jinja-packager
|
|
||||||
|
|
||||||
|
|
||||||
centillion Search:
|
|
||||||
|
|
||||||
- open_index creates the schema
|
|
||||||
|
|
||||||
- add_issue, add_md, add_document have three diff method sigs and add diff types
|
|
||||||
of documents to the search index
|
|
||||||
|
|
||||||
- update_all_issues or update_all_md or update_all_documents iterates over items
|
|
||||||
and determines whether each item needs to be updated in the search index
|
|
||||||
|
|
||||||
- update_main_index - update the entire search index
|
|
||||||
- calls all three update_all methods
|
|
||||||
|
|
||||||
- create_search_results - package things up for jinja
|
|
||||||
|
|
||||||
- search - run the query, pass results to the jinja-packager
|
|
||||||
|
|
||||||
|
|
||||||
Nice to have but focus on it later:
|
|
||||||
|
|
||||||
- update_diff_issues or update_diff_md or update_diff_documents iterates over items
|
|
||||||
and indexes recently-added items
|
|
||||||
|
|
||||||
- update_diff_index - update the diff search index (what's been added since last
|
|
||||||
time)
|
|
||||||
- calls all three update_diff methods
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Files layout
|
|
||||||
|
|
||||||
Schema definition:
|
|
||||||
* include a "kind" or "class" to group objects
|
|
||||||
* can provide different searches of different collections
|
|
||||||
* eventually can provide user with checkboxes
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
173
centillion.py
173
centillion.py
@@ -2,8 +2,11 @@ import threading
|
|||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
import os, json
|
||||||
|
|
||||||
|
from werkzeug.contrib.fixers import ProxyFix
|
||||||
from flask import Flask, request, redirect, url_for, render_template, flash
|
from flask import Flask, request, redirect, url_for, render_template, flash
|
||||||
|
from flask_dance.contrib.github import make_github_blueprint, github
|
||||||
|
|
||||||
# create our application
|
# create our application
|
||||||
from centillion_search import Search
|
from centillion_search import Search
|
||||||
@@ -22,10 +25,12 @@ You provide:
|
|||||||
- Google Drive API key via file
|
- Google Drive API key via file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class UpdateIndexTask(object):
|
class UpdateIndexTask(object):
|
||||||
def __init__(self, diff_index=False):
|
def __init__(self, gh_oauth_token, diff_index=False):
|
||||||
self.diff_index = diff_index
|
self.diff_index = diff_index
|
||||||
thread = threading.Thread(target=self.run, args=())
|
thread = threading.Thread(target=self.run, args=())
|
||||||
|
self.gh_oauth_token = gh_oauth_token
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@@ -38,30 +43,90 @@ class UpdateIndexTask(object):
|
|||||||
from get_centillion_config import get_centillion_config
|
from get_centillion_config import get_centillion_config
|
||||||
config = get_centillion_config('config_centillion.json')
|
config = get_centillion_config('config_centillion.json')
|
||||||
|
|
||||||
gh_token = os.environ['GITHUB_ACESS_TOKEN']
|
search.update_index_markdown(self.gh_oauth_token,config)
|
||||||
search.update_index_issues(gh_token, config)
|
search.update_index_issues(self.gh_oauth_token,config)
|
||||||
search.update_index_gdocs(config)
|
search.update_index_gdocs(config)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app)
|
||||||
|
|
||||||
# Load default config and override config from an environment variable
|
# Load default config and override config from an environment variable
|
||||||
app.config.from_pyfile("config_flask.py")
|
app.config.from_pyfile("config_flask.py")
|
||||||
|
|
||||||
last_searches_file = app.config["INDEX_DIR"] + "/last_searches.txt"
|
github_bp = make_github_blueprint()
|
||||||
|
#github_bp = make_github_blueprint(
|
||||||
|
# client_id = os.environ.get('GITHUB_OAUTH_CLIENT_ID'),
|
||||||
|
# client_secret = os.environ.get('GITHUB_OAUTH_CLIENT_SECRET'),
|
||||||
|
# scope='read:org')
|
||||||
|
|
||||||
|
app.register_blueprint(github_bp, url_prefix="/login")
|
||||||
|
|
||||||
|
contents404 = "<html><body><h1>Status: Error 404 Page Not Found</h1></body></html>"
|
||||||
|
contents403 = "<html><body><h1>Status: Error 403 Access Denied</h1></body></html>"
|
||||||
|
contents200 = "<html><body><h1>Status: OK 200</h1></body></html>"
|
||||||
|
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# Flask routes
|
# Flask routes
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
|
||||||
|
if not github.authorized:
|
||||||
|
return redirect(url_for("github.login"))
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
username = github.get("/user").json()['login']
|
||||||
|
|
||||||
|
resp = github.get("/user/orgs")
|
||||||
|
if resp.ok:
|
||||||
|
|
||||||
|
# If they are in team copper, redirect to search.
|
||||||
|
# Otherwise, hit em with a 403
|
||||||
|
all_orgs = resp.json()
|
||||||
|
for org in all_orgs:
|
||||||
|
if org['login']=='dcppc':
|
||||||
|
copper_team_id = '2700235'
|
||||||
|
mresp = github.get('/teams/%s/members/%s'%(copper_team_id,username))
|
||||||
|
if mresp.status_code==204:
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Business as usual
|
||||||
return redirect(url_for("search", query="", fields=""))
|
return redirect(url_for("search", query="", fields=""))
|
||||||
|
|
||||||
|
return contents403
|
||||||
|
|
||||||
|
return contents404
|
||||||
|
|
||||||
|
### @app.route('/')
|
||||||
|
### def index():
|
||||||
|
### return redirect(url_for("search", query="", fields=""))
|
||||||
|
|
||||||
@app.route('/search')
|
@app.route('/search')
|
||||||
def search():
|
def search():
|
||||||
|
|
||||||
|
if not github.authorized:
|
||||||
|
return redirect(url_for("github.login"))
|
||||||
|
|
||||||
|
username = github.get("/user").json()['login']
|
||||||
|
|
||||||
|
resp = github.get("/user/orgs")
|
||||||
|
if resp.ok:
|
||||||
|
|
||||||
|
all_orgs = resp.json()
|
||||||
|
for org in all_orgs:
|
||||||
|
if org['login']=='dcppc':
|
||||||
|
|
||||||
|
copper_team_id = '2700235'
|
||||||
|
|
||||||
|
mresp = github.get('/teams/%s/members/%s'%(copper_team_id,username))
|
||||||
|
if mresp.status_code==204:
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Business as usual
|
||||||
query = request.args['query']
|
query = request.args['query']
|
||||||
fields = request.args.get('fields')
|
fields = request.args.get('fields')
|
||||||
if fields == 'None':
|
if fields == 'None':
|
||||||
@@ -74,54 +139,82 @@ def search():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
parsed_query, result = search.search(query.split(), fields=[fields])
|
parsed_query, result = search.search(query.split(), fields=[fields])
|
||||||
store_search(query, fields)
|
|
||||||
|
|
||||||
total = search.get_document_total_count()
|
totals = search.get_document_total_count()
|
||||||
|
|
||||||
return render_template('search.html', entries=result, query=query, parsed_query=parsed_query, fields=fields, last_searches=get_last_searches(), total=total)
|
return render_template('search.html',
|
||||||
|
entries=result,
|
||||||
|
query=query,
|
||||||
|
parsed_query=parsed_query,
|
||||||
|
fields=fields,
|
||||||
|
totals=totals)
|
||||||
|
|
||||||
@app.route('/open')
|
return contents403
|
||||||
def open_file():
|
|
||||||
path = request.args['path']
|
|
||||||
fields = request.args.get('fields')
|
|
||||||
query = request.args['query']
|
|
||||||
call([app.config["EDIT_COMMAND"], path])
|
|
||||||
|
|
||||||
return redirect(url_for("search", query=query, fields=fields))
|
|
||||||
|
|
||||||
@app.route('/update_index')
|
@app.route('/update_index')
|
||||||
def update_index():
|
def update_index():
|
||||||
rebuild = request.args.get('rebuild')
|
|
||||||
UpdateIndexTask(diff_index=False)
|
if not github.authorized:
|
||||||
|
return redirect(url_for("github.login"))
|
||||||
|
|
||||||
|
username = github.get("/user").json()['login']
|
||||||
|
|
||||||
|
resp = github.get("/user/orgs")
|
||||||
|
if resp.ok:
|
||||||
|
|
||||||
|
all_orgs = resp.json()
|
||||||
|
for org in all_orgs:
|
||||||
|
if org['login']=='dcppc':
|
||||||
|
|
||||||
|
copper_team_id = '2700235'
|
||||||
|
|
||||||
|
mresp = github.get('/teams/%s/members/%s'%(copper_team_id,username))
|
||||||
|
if mresp.status_code==204:
|
||||||
|
|
||||||
|
gh_oauth_token = github.token['access_token']
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Business as usual
|
||||||
|
UpdateIndexTask(gh_oauth_token, diff_index=False)
|
||||||
flash("Rebuilding index, check console output")
|
flash("Rebuilding index, check console output")
|
||||||
return render_template("search.html", query="", fields="", last_searches=get_last_searches())
|
return render_template("controlpanel.html",
|
||||||
|
totals={})
|
||||||
|
|
||||||
|
return contents403
|
||||||
|
|
||||||
|
|
||||||
##############
|
|
||||||
# Utility methods
|
|
||||||
|
|
||||||
def get_last_searches():
|
@app.route('/control_panel')
|
||||||
if os.path.exists(last_searches_file):
|
def control_panel():
|
||||||
with codecs.open(last_searches_file, 'r', encoding='utf-8') as f:
|
|
||||||
contents = f.readlines()
|
|
||||||
else:
|
|
||||||
contents = []
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def store_search(query, fields):
|
if not github.authorized:
|
||||||
if os.path.exists(last_searches_file):
|
return redirect(url_for("github.login"))
|
||||||
with codecs.open(last_searches_file, 'r', encoding='utf-8') as f:
|
|
||||||
contents = f.readlines()
|
|
||||||
else:
|
|
||||||
contents = []
|
|
||||||
|
|
||||||
search = "query=%s&fields=%s\n" % (query, fields)
|
username = github.get("/user").json()['login']
|
||||||
if not search in contents:
|
|
||||||
contents.insert(0, search)
|
|
||||||
|
|
||||||
with codecs.open(last_searches_file, 'w', encoding='utf-8') as f:
|
resp = github.get("/user/orgs")
|
||||||
f.writelines(contents[:30])
|
if resp.ok:
|
||||||
|
|
||||||
|
all_orgs = resp.json()
|
||||||
|
for org in all_orgs:
|
||||||
|
if org['login']=='dcppc':
|
||||||
|
|
||||||
|
copper_team_id = '2700235'
|
||||||
|
|
||||||
|
mresp = github.get('/teams/%s/members/%s'%(copper_team_id,username))
|
||||||
|
if mresp.status_code==204:
|
||||||
|
|
||||||
|
return render_template("controlpanel.html",
|
||||||
|
totals={})
|
||||||
|
|
||||||
|
return contents403
|
||||||
|
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def oops(e):
|
||||||
|
return contents404
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run(host="0.0.0.0",port=5000)
|
||||||
|
|
||||||
|
5
centillion_prepare.py
Normal file
5
centillion_prepare.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from gdrive_util import GDrive
|
||||||
|
|
||||||
|
gd = GDrive()
|
||||||
|
service = gd.get_service()
|
||||||
|
|
@@ -2,6 +2,7 @@ import shutil
|
|||||||
import html.parser
|
import html.parser
|
||||||
|
|
||||||
from github import Github
|
from github import Github
|
||||||
|
import base64
|
||||||
|
|
||||||
from gdrive_util import GDrive
|
from gdrive_util import GDrive
|
||||||
from apiclient.http import MediaIoBaseDownload
|
from apiclient.http import MediaIoBaseDownload
|
||||||
@@ -14,6 +15,8 @@ import tempfile, subprocess
|
|||||||
import pypandoc
|
import pypandoc
|
||||||
import os.path
|
import os.path
|
||||||
import codecs
|
import codecs
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from whoosh.qparser import MultifieldParser, QueryParser
|
from whoosh.qparser import MultifieldParser, QueryParser
|
||||||
from whoosh.analysis import StemmingAnalyzer
|
from whoosh.analysis import StemmingAnalyzer
|
||||||
|
|
||||||
@@ -40,6 +43,7 @@ Search object functions:
|
|||||||
Schema:
|
Schema:
|
||||||
- id
|
- id
|
||||||
- kind
|
- kind
|
||||||
|
- fingerprint
|
||||||
- created_time
|
- created_time
|
||||||
- modified_time
|
- modified_time
|
||||||
- indexed_time
|
- indexed_time
|
||||||
@@ -57,6 +61,10 @@ Schema:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def clean_timestamp(dt):
|
||||||
|
return dt.replace(microsecond=0).isoformat()
|
||||||
|
|
||||||
|
|
||||||
class SearchResult:
|
class SearchResult:
|
||||||
score = 1.0
|
score = 1.0
|
||||||
path = None
|
path = None
|
||||||
@@ -89,6 +97,11 @@ class Search:
|
|||||||
def __init__(self, index_folder):
|
def __init__(self, index_folder):
|
||||||
self.open_index(index_folder)
|
self.open_index(index_folder)
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------
|
||||||
|
# Create a schema and open a search index
|
||||||
|
# on disk.
|
||||||
|
|
||||||
def open_index(self, index_folder, create_new=False):
|
def open_index(self, index_folder, create_new=False):
|
||||||
"""
|
"""
|
||||||
Create a schema,
|
Create a schema,
|
||||||
@@ -109,13 +122,13 @@ class Search:
|
|||||||
|
|
||||||
|
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# IMPORTANT:
|
|
||||||
# This is where the search index's document schema
|
# This is where the search index's document schema
|
||||||
# is defined.
|
# is defined.
|
||||||
|
|
||||||
schema = Schema(
|
schema = Schema(
|
||||||
id = ID(stored=True, unique=True),
|
id = ID(stored=True, unique=True),
|
||||||
kind = ID(),
|
kind = ID(stored=True),
|
||||||
|
#fingerprint = ID(stored=True),
|
||||||
|
|
||||||
created_time = ID(stored=True),
|
created_time = ID(stored=True),
|
||||||
modified_time = ID(stored=True),
|
modified_time = ID(stored=True),
|
||||||
@@ -154,16 +167,13 @@ class Search:
|
|||||||
# Define how to add documents
|
# Define how to add documents
|
||||||
|
|
||||||
|
|
||||||
def add_drive_file(self, writer, item, indexed_ids, temp_dir, config):
|
def add_drive_file(self, writer, item, temp_dir, config, update=False):
|
||||||
"""
|
"""
|
||||||
Add a Google Drive document/file to a search index.
|
Add a Google Drive document/file to a search index.
|
||||||
If it is a document, extract the contents.
|
If it is a document, extract the contents.
|
||||||
"""
|
"""
|
||||||
gd = GDrive()
|
|
||||||
service = gd.get_service()
|
|
||||||
|
|
||||||
# ------------------------
|
# There are two kinds of documents:
|
||||||
# Two kinds of documents:
|
|
||||||
# - documents with text that can be extracted (docx)
|
# - documents with text that can be extracted (docx)
|
||||||
# - everything else
|
# - everything else
|
||||||
|
|
||||||
@@ -172,10 +182,34 @@ class Search:
|
|||||||
'document' : 'docx',
|
'document' : 'docx',
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mimetype not in mimemap.keys()):
|
content = ""
|
||||||
# Not a document -
|
if mimetype not in mimemap.keys():
|
||||||
# Just a file
|
|
||||||
print("Indexing document %s of type %s"%(item['name'], mimetype))
|
# Not a document - just a file
|
||||||
|
print("Indexing Google Drive file \"%s\" of type %s"%(item['name'], mimetype))
|
||||||
|
writer.delete_by_term('id',item['id'])
|
||||||
|
|
||||||
|
# Index a plain google drive file
|
||||||
|
writer.add_document(
|
||||||
|
id = item['id'],
|
||||||
|
kind = 'gdoc',
|
||||||
|
created_time = item['createdTime'],
|
||||||
|
modified_time = item['modifiedTime'],
|
||||||
|
indexed_time = datetime.now().replace(microsecond=0).isoformat(),
|
||||||
|
title = item['name'],
|
||||||
|
url = item['webViewLink'],
|
||||||
|
mimetype = mimetype,
|
||||||
|
owner_email = item['owners'][0]['emailAddress'],
|
||||||
|
owner_name = item['owners'][0]['displayName'],
|
||||||
|
repo_name='',
|
||||||
|
repo_url='',
|
||||||
|
github_user='',
|
||||||
|
issue_title='',
|
||||||
|
issue_url='',
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Document with text
|
# Document with text
|
||||||
# Perform content extraction
|
# Perform content extraction
|
||||||
@@ -187,7 +221,8 @@ class Search:
|
|||||||
# This is a file type we know how to convert
|
# This is a file type we know how to convert
|
||||||
# Construct the URL and download it
|
# Construct the URL and download it
|
||||||
|
|
||||||
print("Extracting content from %s of type %s"%(item['name'], mimetype))
|
print("Indexing Google Drive document \"%s\" of type %s"%(item['name'], mimetype))
|
||||||
|
print(" > Extracting content")
|
||||||
|
|
||||||
|
|
||||||
# Create a URL and a destination filename
|
# Create a URL and a destination filename
|
||||||
@@ -208,7 +243,7 @@ class Search:
|
|||||||
outfile_name = name+'.'+out_ext
|
outfile_name = name+'.'+out_ext
|
||||||
|
|
||||||
|
|
||||||
# assemble input/output file paths
|
# Assemble input/output file paths
|
||||||
fullpath_input = os.path.join(temp_dir,infile_name)
|
fullpath_input = os.path.join(temp_dir,infile_name)
|
||||||
fullpath_output = os.path.join(temp_dir,outfile_name)
|
fullpath_output = os.path.join(temp_dir,outfile_name)
|
||||||
|
|
||||||
@@ -227,7 +262,7 @@ class Search:
|
|||||||
)
|
)
|
||||||
assert output == ""
|
assert output == ""
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
print("XXXXXX Failed to index document %s"%(item['name']))
|
print(" > XXXXXX Failed to index document \"%s\""%(item['name']))
|
||||||
|
|
||||||
|
|
||||||
# If export was successful, read contents of markdown
|
# If export was successful, read contents of markdown
|
||||||
@@ -240,7 +275,7 @@ class Search:
|
|||||||
|
|
||||||
|
|
||||||
# No matter what happens, clean up.
|
# No matter what happens, clean up.
|
||||||
print("Cleaning up %s"%item['name'])
|
print(" > Cleaning up \"%s\""%item['name'])
|
||||||
|
|
||||||
subprocess.call(['rm','-fr',fullpath_output])
|
subprocess.call(['rm','-fr',fullpath_output])
|
||||||
#print(" ".join(['rm','-fr',fullpath_output]))
|
#print(" ".join(['rm','-fr',fullpath_output]))
|
||||||
@@ -248,80 +283,147 @@ class Search:
|
|||||||
subprocess.call(['rm','-fr',fullpath_input])
|
subprocess.call(['rm','-fr',fullpath_input])
|
||||||
#print(" ".join(['rm','-fr',fullpath_input]))
|
#print(" ".join(['rm','-fr',fullpath_input]))
|
||||||
|
|
||||||
|
if update:
|
||||||
|
print(" > Removing old record")
|
||||||
|
writer.delete_by_term('id',item['id'])
|
||||||
|
else:
|
||||||
|
print(" > Creating a new record")
|
||||||
|
|
||||||
# ------------------------------
|
|
||||||
# IMPORTANT:
|
|
||||||
# This is where the search documents are actually created.
|
|
||||||
|
|
||||||
mimetype = re.split('[/\.]', item['mimeType'])[-1]
|
|
||||||
writer.add_document(
|
writer.add_document(
|
||||||
id = item['id'],
|
id = item['id'],
|
||||||
kind = 'gdoc',
|
kind = 'gdoc',
|
||||||
created_time = item['createdTime'],
|
created_time = item['createdTime'],
|
||||||
modified_time = item['modifiedTime'],
|
modified_time = item['modifiedTime'],
|
||||||
|
indexed_time = datetime.now().replace(microsecond=0).isoformat(),
|
||||||
title = item['name'],
|
title = item['name'],
|
||||||
url = item['webViewLink'],
|
url = item['webViewLink'],
|
||||||
mimetype = mimetype,
|
mimetype = mimetype,
|
||||||
owner_email = item['owners'][0]['emailAddress'],
|
owner_email = item['owners'][0]['emailAddress'],
|
||||||
owner_name = item['owners'][0]['displayName'],
|
owner_name = item['owners'][0]['displayName'],
|
||||||
repo_name=None,
|
repo_name='',
|
||||||
repo_url=None,
|
repo_url='',
|
||||||
github_user=None,
|
github_user='',
|
||||||
issue_title=None,
|
issue_title='',
|
||||||
issue_url=None,
|
issue_url='',
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_issue(self, writer, issue, repo, config):
|
|
||||||
|
|
||||||
|
# ------------------------------
|
||||||
|
# Add a single github issue and its comments
|
||||||
|
# to a search index.
|
||||||
|
|
||||||
|
|
||||||
|
def add_issue(self, writer, issue, config, update=True):
|
||||||
"""
|
"""
|
||||||
Add a Github issue/comment to a search index.
|
Add a Github issue/comment to a search index.
|
||||||
"""
|
"""
|
||||||
repo_name = repo.name
|
repo = issue.repository
|
||||||
|
repo_name = repo.owner.login+"/"+repo.name
|
||||||
repo_url = repo.html_url
|
repo_url = repo.html_url
|
||||||
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
|
|
||||||
# Handle the issue content
|
|
||||||
print("Indexing issue %s"%(issue.html_url))
|
print("Indexing issue %s"%(issue.html_url))
|
||||||
writer.add_document(
|
|
||||||
id = issue.html_url,
|
|
||||||
kind = 'issue',
|
|
||||||
url = issue.html_url,
|
|
||||||
is_comment = False,
|
|
||||||
timestamp = issue.created_at,
|
|
||||||
repo_name = repo_name,
|
|
||||||
repo_url = repo_url,
|
|
||||||
issue_title = issue.title,
|
|
||||||
issue_url = issue.html_url,
|
|
||||||
user = issue.user.login,
|
|
||||||
content = issue.body.rstrip()
|
|
||||||
)
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
|
# Combine comments with their respective issues.
|
||||||
|
# Otherwise just too noisy.
|
||||||
|
issue_comment_content = issue.body.rstrip()
|
||||||
|
issue_comment_content += "\n"
|
||||||
|
|
||||||
# Handle the comments content
|
# Handle the comments content
|
||||||
if(issue.comments>0):
|
if(issue.comments>0):
|
||||||
|
|
||||||
comments = issue.get_comments()
|
comments = issue.get_comments()
|
||||||
for comment in comments:
|
for comment in comments:
|
||||||
print(" > Indexing comment %s"%(comment.html_url))
|
|
||||||
|
issue_comment_content += comment.body.rstrip()
|
||||||
|
issue_comment_content += "\n"
|
||||||
|
|
||||||
|
# Now create the actual search index record
|
||||||
|
created_time = clean_timestamp(issue.created_at)
|
||||||
|
modified_time = clean_timestamp(issue.updated_at)
|
||||||
|
indexed_time = clean_timestamp(datetime.now())
|
||||||
|
|
||||||
|
# Add one document per issue thread,
|
||||||
|
# containing entire text of thread.
|
||||||
writer.add_document(
|
writer.add_document(
|
||||||
id = comment.html_url,
|
id = issue.html_url,
|
||||||
kind = 'comment',
|
kind = 'issue',
|
||||||
url = comment.html_url,
|
created_time = created_time,
|
||||||
is_comment = True,
|
modified_time = modified_time,
|
||||||
timestamp = comment.created_at,
|
indexed_time = indexed_time,
|
||||||
|
title = issue.title,
|
||||||
|
url = issue.html_url,
|
||||||
|
mimetype='',
|
||||||
|
owner_email='',
|
||||||
|
owner_name='',
|
||||||
repo_name = repo_name,
|
repo_name = repo_name,
|
||||||
repo_url = repo_url,
|
repo_url = repo_url,
|
||||||
|
github_user = issue.user.login,
|
||||||
issue_title = issue.title,
|
issue_title = issue.title,
|
||||||
issue_url = issue.html_url,
|
issue_url = issue.html_url,
|
||||||
user = comment.user.login,
|
content = issue_comment_content
|
||||||
content = comment.body.strip()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
count += 1
|
|
||||||
return count
|
|
||||||
|
def add_markdown(self, writer, d, config, update=True):
|
||||||
|
"""
|
||||||
|
Use a Github markdown document API record
|
||||||
|
to add a markdown document's contents to
|
||||||
|
the search index.
|
||||||
|
"""
|
||||||
|
repo = d['repo']
|
||||||
|
org = d['org']
|
||||||
|
repo_name = org + "/" + repo
|
||||||
|
repo_url = "https://github.com/" + repo_name
|
||||||
|
|
||||||
|
fpath = d['path']
|
||||||
|
furl = d['url']
|
||||||
|
fsha = d['sha']
|
||||||
|
_, fname = os.path.split(fpath)
|
||||||
|
_, fext = os.path.splitext(fpath)
|
||||||
|
|
||||||
|
print("Indexing markdown doc %s"%(fname))
|
||||||
|
|
||||||
|
# Unpack the requests response and decode the content
|
||||||
|
response = requests.get(furl)
|
||||||
|
jresponse = response.json()
|
||||||
|
content = ""
|
||||||
|
try:
|
||||||
|
binary_content = re.sub('\n','',jresponse['content'])
|
||||||
|
content = base64.b64decode(binary_content).decode('utf-8')
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
print(" > XXXXXXXX Failed to extract 'content' field. You probably hit the rate limit.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Now create the actual search index record
|
||||||
|
indexed_time = clean_timestamp(datetime.now())
|
||||||
|
|
||||||
|
usable_url = "https://github.com/%s/blob/master/%s"%(repo_name, fpath)
|
||||||
|
|
||||||
|
# Add one document per issue thread,
|
||||||
|
# containing entire text of thread.
|
||||||
|
writer.add_document(
|
||||||
|
id = fsha,
|
||||||
|
kind = 'markdown',
|
||||||
|
created_time = '',
|
||||||
|
modified_time = '',
|
||||||
|
indexed_time = indexed_time,
|
||||||
|
title = fname,
|
||||||
|
url = usable_url,
|
||||||
|
mimetype='',
|
||||||
|
owner_email='',
|
||||||
|
owner_name='',
|
||||||
|
repo_name = repo_name,
|
||||||
|
repo_url = repo_url,
|
||||||
|
github_user = '',
|
||||||
|
issue_title = '',
|
||||||
|
issue_url = '',
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -334,128 +436,327 @@ class Search:
|
|||||||
"""
|
"""
|
||||||
Update the search index using a collection of
|
Update the search index using a collection of
|
||||||
Google Drive documents and files.
|
Google Drive documents and files.
|
||||||
|
|
||||||
|
Uses the 'id' field to uniquely identify documents.
|
||||||
|
|
||||||
|
Also see:
|
||||||
|
https://developers.google.com/drive/api/v3/reference/files
|
||||||
"""
|
"""
|
||||||
gd = GDrive()
|
|
||||||
service = gd.get_service()
|
|
||||||
|
|
||||||
# -----
|
# Updated algorithm:
|
||||||
# Get the set of all documents on Google Drive:
|
# - get set of indexed ids
|
||||||
|
# - get set of remote ids
|
||||||
|
# - drop indexed ids not in remote ids
|
||||||
|
# - index all remote ids
|
||||||
|
# - add hash check in add_
|
||||||
|
|
||||||
# ------------------------------
|
|
||||||
# IMPORTANT:
|
|
||||||
# This determines what information about the Google Drive files
|
|
||||||
# you'll get back, and that's all you're going to have to work with.
|
|
||||||
# If you need more information, modify the statement below.
|
|
||||||
# Also see:
|
|
||||||
# https://developers.google.com/drive/api/v3/reference/files
|
|
||||||
|
|
||||||
|
# Get the set of indexed ids:
|
||||||
|
# ------
|
||||||
|
indexed_ids = set()
|
||||||
|
p = QueryParser("kind", schema=self.ix.schema)
|
||||||
|
q = p.parse("gdoc")
|
||||||
|
with self.ix.searcher() as s:
|
||||||
|
results = s.search(q,limit=None)
|
||||||
|
for result in results:
|
||||||
|
indexed_ids.add(result['id'])
|
||||||
|
|
||||||
|
|
||||||
|
# Get the set of remote ids:
|
||||||
|
# ------
|
||||||
|
# Start with google drive api object
|
||||||
gd = GDrive()
|
gd = GDrive()
|
||||||
service = gd.get_service()
|
service = gd.get_service()
|
||||||
drive = service.files()
|
drive = service.files()
|
||||||
|
|
||||||
|
# Now index all the docs in the google drive folder
|
||||||
|
|
||||||
# The trick is to set next page token to None 1st time thru (fencepost)
|
# The trick is to set next page token to None 1st time thru (fencepost)
|
||||||
nextPageToken = None
|
nextPageToken = None
|
||||||
|
|
||||||
# Use the pager to return all the things
|
# Use the pager to return all the things
|
||||||
items = []
|
remote_ids = set()
|
||||||
|
full_items = {}
|
||||||
while True:
|
while True:
|
||||||
|
ps = 12
|
||||||
results = drive.list(
|
results = drive.list(
|
||||||
pageSize=100,
|
pageSize=ps,
|
||||||
pageToken=nextPageToken,
|
pageToken=nextPageToken,
|
||||||
fields="files(id, kind, createdTime, modifiedTime, mimeType, name, owners, webViewLink)",
|
fields = "nextPageToken, files(id, kind, createdTime, modifiedTime, mimeType, name, owners, webViewLink)",
|
||||||
spaces="drive"
|
spaces="drive"
|
||||||
).execute()
|
).execute()
|
||||||
|
|
||||||
nextPageToken = results.get("nextPageToken")
|
nextPageToken = results.get("nextPageToken")
|
||||||
items += results.get("files", [])
|
files = results.get("files",[])
|
||||||
|
for f in files:
|
||||||
|
|
||||||
if nextPageToken is None:
|
# Add all remote docs to a set
|
||||||
|
remote_ids.add(f['id'])
|
||||||
|
|
||||||
|
# Also store the doc
|
||||||
|
full_items[f['id']] = f
|
||||||
|
|
||||||
|
# Shorter:
|
||||||
break
|
break
|
||||||
|
## Longer:
|
||||||
|
#if nextPageToken is None:
|
||||||
|
# break
|
||||||
|
|
||||||
indexed_ids = set()
|
|
||||||
for item in items:
|
|
||||||
indexed_ids.add(item['id'])
|
|
||||||
|
|
||||||
writer = self.ix.writer()
|
writer = self.ix.writer()
|
||||||
|
count = 0
|
||||||
temp_dir = tempfile.mkdtemp(dir=os.getcwd())
|
temp_dir = tempfile.mkdtemp(dir=os.getcwd())
|
||||||
print("Temporary directory: %s"%(temp_dir))
|
print("Temporary directory: %s"%(temp_dir))
|
||||||
if not os.path.exists(temp_dir):
|
|
||||||
os.mkdir(temp_dir)
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
for item in items:
|
|
||||||
self.add_item(writer, item, indexed_ids, temp_dir, config)
|
# Drop any id in indexed_ids
|
||||||
|
# not in remote_ids
|
||||||
|
drop_ids = indexed_ids - remote_ids
|
||||||
|
for drop_id in drop_ids:
|
||||||
|
writer.delete_by_term('id',drop_id)
|
||||||
|
|
||||||
|
|
||||||
|
# Update any id in indexed_ids
|
||||||
|
# and in remote_ids
|
||||||
|
update_ids = indexed_ids & remote_ids
|
||||||
|
for update_id in update_ids:
|
||||||
|
# cop out
|
||||||
|
writer.delete_by_term('id',update_id)
|
||||||
|
item = full_items[update_id]
|
||||||
|
self.add_drive_file(writer, item, temp_dir, config, update=True)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
# Add any id not in indexed_ids
|
||||||
|
# and in remote_ids
|
||||||
|
add_ids = remote_ids - indexed_ids
|
||||||
|
for add_id in add_ids:
|
||||||
|
item = full_items[add_id]
|
||||||
|
self.add_drive_file(writer, item, temp_dir, config, update=False)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
print("Cleaning temporary directory: %s"%(temp_dir))
|
||||||
|
subprocess.call(['rm','-fr',temp_dir])
|
||||||
|
|
||||||
writer.commit()
|
writer.commit()
|
||||||
print("Done, updated %d documents in the index" % count)
|
print("Done, updated %d documents in the index" % count)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def update_index_issues(self, gh_oauth_token, config):
|
||||||
def update_index_issues(self,
|
|
||||||
gh_access_token,
|
|
||||||
config):
|
|
||||||
"""
|
"""
|
||||||
Update the search index using a collection of
|
Update the search index using a collection of
|
||||||
Github repo issues and comments.
|
Github repo issues and comments.
|
||||||
|
|
||||||
|
gh_oauth_token can also be an access token.
|
||||||
"""
|
"""
|
||||||
# Strategy:
|
# Updated algorithm:
|
||||||
# To get the proof of concept up and running,
|
# - get set of indexed ids
|
||||||
# we are just deleting and re-indexing every issue/comment.
|
# - get set of remote ids
|
||||||
|
# - drop indexed ids not in remote ids
|
||||||
|
# - index all remote ids
|
||||||
|
|
||||||
g = Github(gh_access_token)
|
# Get the set of indexed ids:
|
||||||
|
# ------
|
||||||
|
indexed_issues = set()
|
||||||
|
p = QueryParser("kind", schema=self.ix.schema)
|
||||||
|
q = p.parse("gdoc")
|
||||||
|
with self.ix.searcher() as s:
|
||||||
|
results = s.search(q,limit=None)
|
||||||
|
for result in results:
|
||||||
|
indexed_issues.add(result['id'])
|
||||||
|
|
||||||
# Set of all URLs as existing on github
|
|
||||||
to_index = set()
|
|
||||||
|
|
||||||
writer = self.ix.writer()
|
# Get the set of remote ids:
|
||||||
|
# ------
|
||||||
|
# Start with api object
|
||||||
|
g = Github(gh_oauth_token)
|
||||||
|
|
||||||
|
# Now index all issue threads in the user-specified repos
|
||||||
|
|
||||||
# Iterate over each repo
|
# Iterate over each repo
|
||||||
list_of_repos = config['repos']
|
list_of_repos = config['repositories']
|
||||||
for r in list_of_repos:
|
for r in list_of_repos:
|
||||||
|
|
||||||
|
# Start by collecting all the things
|
||||||
|
remote_issues = set()
|
||||||
|
full_items = {}
|
||||||
|
|
||||||
if '/' not in r:
|
if '/' not in r:
|
||||||
err = "Error: specify org/reponame or user/reponame in list of repos"
|
err = "Error: specify org/reponame or user/reponame in list of repos"
|
||||||
raise Exception(err)
|
raise Exception(err)
|
||||||
|
|
||||||
this_repo, this_org = re.split('/',r)
|
this_org, this_repo = re.split('/',r)
|
||||||
|
|
||||||
org = g.get_organization(this_org)
|
org = g.get_organization(this_org)
|
||||||
repo = org.get_repo(this_repo)
|
repo = org.get_repo(this_repo)
|
||||||
|
|
||||||
count = 0
|
# Iterate over each issue thread
|
||||||
|
|
||||||
# Iterate over each thread
|
|
||||||
issues = repo.get_issues()
|
issues = repo.get_issues()
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
|
|
||||||
# This approach is more work than is needed
|
|
||||||
# but PoC||GTFO
|
|
||||||
|
|
||||||
# For each issue/comment URL,
|
# For each issue/comment URL,
|
||||||
# remove the corresponding item
|
# grab the key and store the
|
||||||
# and re-add it to the index
|
# corresponding issue object
|
||||||
|
key = issue.html_url
|
||||||
|
value = issue
|
||||||
|
|
||||||
to_index.add(issue.html_url)
|
remote_issues.add(key)
|
||||||
writer.delete_by_term('url', issue.html_url)
|
full_items[key] = value
|
||||||
comments = issue.get_comments()
|
|
||||||
|
|
||||||
for comment in comments:
|
writer = self.ix.writer()
|
||||||
to_index.add(comment.html_url)
|
count = 0
|
||||||
writer.delete_by_term('url', comment.html_url)
|
|
||||||
|
|
||||||
# Now re-add this issue to the index
|
# Drop any issues in indexed_issues
|
||||||
# (this will also add the comments)
|
# not in remote_issues
|
||||||
count += self.add_issue(writer, issue, repo, config)
|
drop_issues = indexed_issues - remote_issues
|
||||||
|
for drop_issue in drop_issues:
|
||||||
|
writer.delete_by_term('id',drop_issue)
|
||||||
|
|
||||||
|
|
||||||
|
# Update any issue in indexed_issues
|
||||||
|
# and in remote_issues
|
||||||
|
update_issues = indexed_issues & remote_issues
|
||||||
|
for update_issue in update_issues:
|
||||||
|
# cop out
|
||||||
|
writer.delete_by_term('id',update_issue)
|
||||||
|
item = full_items[update_issue]
|
||||||
|
self.add_issue(writer, item, config, update=True)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
# Add any issue not in indexed_issues
|
||||||
|
# and in remote_issues
|
||||||
|
add_issues = remote_issues - indexed_issues
|
||||||
|
for add_issue in add_issues:
|
||||||
|
item = full_items[add_issue]
|
||||||
|
self.add_issue(writer, item, config, update=False)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
writer.commit()
|
writer.commit()
|
||||||
print("Done, updated %d documents in the index" % count)
|
print("Done, updated %d documents in the index" % count)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def update_index_markdown(self, gh_oauth_token, config):
|
||||||
|
"""
|
||||||
|
Update the search index using a collection of
|
||||||
|
Markdown files from a Github repo.
|
||||||
|
|
||||||
|
gh_oauth_token can also be an access token.
|
||||||
|
"""
|
||||||
|
EXT = '.md'
|
||||||
|
|
||||||
|
# Updated algorithm:
|
||||||
|
# - get set of indexed ids
|
||||||
|
# - get set of remote ids
|
||||||
|
# - drop indexed ids not in remote ids
|
||||||
|
# - index all remote ids
|
||||||
|
|
||||||
|
# Get the set of indexed ids:
|
||||||
|
# ------
|
||||||
|
indexed_ids = set()
|
||||||
|
p = QueryParser("kind", schema=self.ix.schema)
|
||||||
|
q = p.parse("markdown")
|
||||||
|
with self.ix.searcher() as s:
|
||||||
|
results = s.search(q,limit=None)
|
||||||
|
for result in results:
|
||||||
|
indexed_ids.add(result['id'])
|
||||||
|
|
||||||
|
# Get the set of remote ids:
|
||||||
|
# ------
|
||||||
|
# Start with api object
|
||||||
|
g = Github(gh_oauth_token)
|
||||||
|
|
||||||
|
# Now index all markdown files
|
||||||
|
# in the user-specified repos
|
||||||
|
|
||||||
|
# Iterate over each repo
|
||||||
|
list_of_repos = config['repositories']
|
||||||
|
for r in list_of_repos:
|
||||||
|
|
||||||
|
# Start by collecting all the things
|
||||||
|
remote_ids = set()
|
||||||
|
full_items = {}
|
||||||
|
|
||||||
|
if '/' not in r:
|
||||||
|
err = "Error: specify org/reponame or user/reponame in list of repos"
|
||||||
|
raise Exception(err)
|
||||||
|
|
||||||
|
this_org, this_repo = re.split('/',r)
|
||||||
|
org = g.get_organization(this_org)
|
||||||
|
repo = org.get_repo(this_repo)
|
||||||
|
|
||||||
|
# ---------
|
||||||
|
# begin markdown-specific code
|
||||||
|
|
||||||
|
# Get head commit
|
||||||
|
commits = repo.get_commits()
|
||||||
|
last = commits[0]
|
||||||
|
sha = last.sha
|
||||||
|
|
||||||
|
# Get all the docs
|
||||||
|
tree = repo.get_git_tree(sha=sha, recursive=True)
|
||||||
|
docs = tree.raw_data['tree']
|
||||||
|
|
||||||
|
for d in docs:
|
||||||
|
|
||||||
|
# For each doc, get the file extension
|
||||||
|
# If it matches EXT, download the file
|
||||||
|
fpath = d['path']
|
||||||
|
_, fname = os.path.split(fpath)
|
||||||
|
_, fext = os.path.splitext(fpath)
|
||||||
|
|
||||||
|
if fext==EXT:
|
||||||
|
|
||||||
|
key = d['sha']
|
||||||
|
d['org'] = this_org
|
||||||
|
d['repo'] = this_repo
|
||||||
|
value = d
|
||||||
|
|
||||||
|
# Stash the doc for later
|
||||||
|
remote_ids.add(key)
|
||||||
|
full_items[key] = value
|
||||||
|
|
||||||
|
writer = self.ix.writer()
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
|
||||||
|
# Drop any id in indexed_ids
|
||||||
|
# not in remote_ids
|
||||||
|
drop_ids = indexed_ids - remote_ids
|
||||||
|
for drop_id in drop_ids:
|
||||||
|
writer.delete_by_term('id',drop_id)
|
||||||
|
|
||||||
|
|
||||||
|
# Update any id in indexed_ids
|
||||||
|
# and in remote_ids
|
||||||
|
update_ids = indexed_ids & remote_ids
|
||||||
|
for update_id in update_ids:
|
||||||
|
# cop out
|
||||||
|
writer.delete_by_term('id',update_id)
|
||||||
|
item = full_items[update_id]
|
||||||
|
self.add_markdown(writer, item, config, update=True)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
# Add any issue not in indexed_ids
|
||||||
|
# and in remote_ids
|
||||||
|
add_ids = remote_ids - indexed_ids
|
||||||
|
for add_id in add_ids:
|
||||||
|
item = full_items[add_id]
|
||||||
|
self.add_markdown(writer, item, config, update=False)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
writer.commit()
|
||||||
|
print("Done, updated %d markdown documents in the index" % count)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Search results bundler
|
# Search results bundler
|
||||||
|
|
||||||
@@ -477,11 +778,6 @@ class Search:
|
|||||||
# contains a {% for e in entries %}
|
# contains a {% for e in entries %}
|
||||||
# and then an {{e.score}}
|
# and then an {{e.score}}
|
||||||
|
|
||||||
|
|
||||||
# ------------------
|
|
||||||
# cheseburger
|
|
||||||
# create search results
|
|
||||||
|
|
||||||
sr = SearchResult()
|
sr = SearchResult()
|
||||||
sr.score = r.score
|
sr.score = r.score
|
||||||
|
|
||||||
@@ -495,37 +791,29 @@ class Search:
|
|||||||
|
|
||||||
sr.id = r['id']
|
sr.id = r['id']
|
||||||
sr.kind = r['kind']
|
sr.kind = r['kind']
|
||||||
sr.url = r['url']
|
|
||||||
|
sr.created_time = r['created_time']
|
||||||
|
sr.modified_time = r['modified_time']
|
||||||
|
sr.indexed_time = r['indexed_time']
|
||||||
|
|
||||||
sr.title = r['title']
|
sr.title = r['title']
|
||||||
|
sr.url = r['url']
|
||||||
|
|
||||||
sr.mimetype = r['mimetype']
|
sr.mimetype = r['mimetype']
|
||||||
|
|
||||||
sr.owner_email = r['owner_email']
|
sr.owner_email = r['owner_email']
|
||||||
sr.owner_name = r['owner_name']
|
sr.owner_name = r['owner_name']
|
||||||
|
|
||||||
sr.content = r['content']
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
|
||||||
# github isuses
|
|
||||||
# create search results
|
|
||||||
|
|
||||||
sr = SearchResult()
|
|
||||||
sr.score = r.score
|
|
||||||
sr.url = r['url']
|
|
||||||
sr.title = r['issue_title']
|
|
||||||
|
|
||||||
sr.repo_name = r['repo_name']
|
sr.repo_name = r['repo_name']
|
||||||
sr.repo_url = r['repo_url']
|
sr.repo_url = r['repo_url']
|
||||||
|
|
||||||
sr.issue_title = r['issue_title']
|
sr.issue_title = r['issue_title']
|
||||||
sr.issue_url = r['issue_url']
|
sr.issue_url = r['issue_url']
|
||||||
|
|
||||||
sr.is_comment = r['is_comment']
|
sr.github_user = r['github_user']
|
||||||
|
|
||||||
sr.content = r['content']
|
sr.content = r['content']
|
||||||
|
|
||||||
# ------------------
|
|
||||||
|
|
||||||
highlights = r.highlights('content')
|
highlights = r.highlights('content')
|
||||||
if not highlights:
|
if not highlights:
|
||||||
# just use the first 1,000 words of the document
|
# just use the first 1,000 words of the document
|
||||||
@@ -533,21 +821,18 @@ class Search:
|
|||||||
|
|
||||||
highlights = self.html_parser.unescape(highlights)
|
highlights = self.html_parser.unescape(highlights)
|
||||||
html = self.markdown(highlights)
|
html = self.markdown(highlights)
|
||||||
|
html = re.sub(r'\n','<br />',html)
|
||||||
sr.content_highlight = html
|
sr.content_highlight = html
|
||||||
|
|
||||||
search_results.append(sr)
|
search_results.append(sr)
|
||||||
|
|
||||||
return search_results
|
return search_results
|
||||||
|
|
||||||
# ------------------
|
|
||||||
# github issues
|
|
||||||
# create search results
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def search(self, query_list, fields=None):
|
def search(self, query_list, fields=None):
|
||||||
|
|
||||||
with self.ix.searcher() as searcher:
|
with self.ix.searcher() as searcher:
|
||||||
query_string = " ".join(query_list)
|
query_string = " ".join(query_list)
|
||||||
query = None
|
query = None
|
||||||
@@ -558,27 +843,15 @@ class Search:
|
|||||||
elif len(fields) == 2:
|
elif len(fields) == 2:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
fields = ['id',
|
# If the user does not specify a field,
|
||||||
'kind',
|
# these are the fields that are actually searched
|
||||||
'created_time',
|
fields = ['title',
|
||||||
'modified_time',
|
|
||||||
'indexed_time',
|
|
||||||
'title',
|
|
||||||
'url',
|
|
||||||
'mimetype',
|
|
||||||
'owner_email',
|
|
||||||
'owner_name',
|
|
||||||
'repo_name',
|
|
||||||
'repo_url',
|
|
||||||
'issue_title',
|
|
||||||
'issue_url',
|
|
||||||
'github_user',
|
|
||||||
'content']
|
'content']
|
||||||
if not query:
|
if not query:
|
||||||
query = MultifieldParser(fields, schema=self.ix.schema).parse(query_string)
|
query = MultifieldParser(fields, schema=self.ix.schema).parse(query_string)
|
||||||
parsed_query = "%s" % query
|
parsed_query = "%s" % query
|
||||||
print("query: %s" % parsed_query)
|
print("query: %s" % parsed_query)
|
||||||
results = searcher.search(query, terms=False, scored=True, groupedby="url")
|
results = searcher.search(query, terms=False, scored=True, groupedby="kind")
|
||||||
search_result = self.create_search_result(results)
|
search_result = self.create_search_result(results)
|
||||||
|
|
||||||
return parsed_query, search_result
|
return parsed_query, search_result
|
||||||
@@ -589,7 +862,31 @@ class Search:
|
|||||||
return s if len(s) <= l else s[0:l - 3] + '...'
|
return s if len(s) <= l else s[0:l - 3] + '...'
|
||||||
|
|
||||||
def get_document_total_count(self):
|
def get_document_total_count(self):
|
||||||
return self.ix.searcher().doc_count_all()
|
p = QueryParser("kind", schema=self.ix.schema)
|
||||||
|
|
||||||
|
kind_labels = {
|
||||||
|
"documents" : "gdoc",
|
||||||
|
"markdown" : "markdown",
|
||||||
|
"issues" : "issue",
|
||||||
|
}
|
||||||
|
counts = {
|
||||||
|
"documents" : None,
|
||||||
|
"markdown" : None,
|
||||||
|
"issues" : None,
|
||||||
|
"total" : None
|
||||||
|
}
|
||||||
|
for key in kind_labels:
|
||||||
|
kind = kind_labels[key]
|
||||||
|
q = p.parse(kind)
|
||||||
|
with self.ix.searcher() as s:
|
||||||
|
results = s.search(q,limit=None)
|
||||||
|
counts[key] = len(results)
|
||||||
|
|
||||||
|
## These two should NOT be different, but they are...
|
||||||
|
#counts['total'] = self.ix.searcher().doc_count_all()
|
||||||
|
counts['total'] = counts['documents'] + counts['markdown'] + counts['issues']
|
||||||
|
|
||||||
|
return counts
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
search = Search("search_index")
|
search = Search("search_index")
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"repositories" : [
|
"repositories" : [
|
||||||
"dcppc/2018-june-workshop",
|
"dcppc/2018-june-workshop",
|
||||||
"dcppc/2018-july-workshop",
|
"dcppc/2018-july-workshop"
|
||||||
"dcppc/data-stewards"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,26 +1,18 @@
|
|||||||
# Path to markdown files
|
|
||||||
MARKDOWN_FILES_DIR = "/Users/charles/codes/whoosh/markdown-search/fake-docs/"
|
|
||||||
|
|
||||||
# Location of index file
|
# Location of index file
|
||||||
INDEX_DIR = "search_index"
|
INDEX_DIR = "search_index"
|
||||||
|
|
||||||
# Command to use when clicking on filepath in search results
|
# oauth client deets
|
||||||
EDIT_COMMAND = "view"
|
GITHUB_OAUTH_CLIENT_ID = "63f8d49c651840cbe31e"
|
||||||
|
GITHUB_OAUTH_CLIENT_SECRET = "36d9a4611f7427336d3c89ed041c45d086b793ee"
|
||||||
|
|
||||||
|
# More information footer: Repository label
|
||||||
|
FOOTER_REPO_ORG = "charlesreid1"
|
||||||
|
FOOTER_REPO_NAME = "centillion"
|
||||||
|
|
||||||
# Toggle to show Whoosh parsed query
|
# Toggle to show Whoosh parsed query
|
||||||
SHOW_PARSED_QUERY=True
|
SHOW_PARSED_QUERY=True
|
||||||
|
|
||||||
# Toogle to use tags
|
TAGLINE = "Search all the things"
|
||||||
USE_TAGS=True
|
|
||||||
|
|
||||||
# Optional prefix in a markdown file, e.g. "tags: python search markdown tutorial"
|
|
||||||
TAGS_PREFIX=""
|
|
||||||
|
|
||||||
# List of tags that should be ignored
|
|
||||||
TAGS_TO_IGNORE = "and are what how its not with the"
|
|
||||||
|
|
||||||
# Regular expression to select tags, eg tag has to start with alphanumeric followed by at least two alphanumeric or "-" or "."
|
|
||||||
TAGS_REGEX = r"\b([A-Za-z0-9][A-Za-z0-9-.]{2,})\b"
|
|
||||||
|
|
||||||
# Flask settings
|
# Flask settings
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
22
docs/centillion_components.md
Normal file
22
docs/centillion_components.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Centillion Components
|
||||||
|
|
||||||
|
Centillion keeps it simple.
|
||||||
|
|
||||||
|
There are two components:
|
||||||
|
|
||||||
|
* The `Search` object, which uses whoosh and various
|
||||||
|
APIs (Github, Google Drive) to build and manage
|
||||||
|
the search index. The `Search` object also runs all
|
||||||
|
queries against the search index. (See the
|
||||||
|
[Centillion Whoosh](centillion_whoosh.md) page
|
||||||
|
or the `centillion_search`.py` file
|
||||||
|
for details.)
|
||||||
|
|
||||||
|
* Flask app, which uses Jinja templates to present the
|
||||||
|
user with a minimal web frontend that allows them
|
||||||
|
to interact with the search engine. (See the
|
||||||
|
[Centillion Flask](centillion_flask.md) page
|
||||||
|
or the `centillion`.py` file
|
||||||
|
for details.)
|
||||||
|
|
||||||
|
|
30
docs/centillion_flask.md
Normal file
30
docs/centillion_flask.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Centillion Flask
|
||||||
|
|
||||||
|
## What the flask server does
|
||||||
|
|
||||||
|
Flask is a web server framework
|
||||||
|
that allows developers to define
|
||||||
|
behavior for specific endpoints,
|
||||||
|
such as `/hello_world`, or
|
||||||
|
<http://localhost:5000/hello_world>
|
||||||
|
on a web server running locally.
|
||||||
|
|
||||||
|
## Flask server routes
|
||||||
|
|
||||||
|
- `/home`
|
||||||
|
- if not logged in, this redirects to a "log into github" landing page (not implemented yet)
|
||||||
|
- if logged in, this redirects to the search route
|
||||||
|
|
||||||
|
- `/search`
|
||||||
|
- search template
|
||||||
|
|
||||||
|
- `/main_index_update`
|
||||||
|
- update main index, all docs period
|
||||||
|
|
||||||
|
- `/control_panel`
|
||||||
|
- this is the control panel, where you can trigger
|
||||||
|
the search index to be re-made
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
34
docs/centillion_whoosh.md
Normal file
34
docs/centillion_whoosh.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Centillion Whoosh
|
||||||
|
|
||||||
|
The `centillion_search.py` file defines a
|
||||||
|
`Search` class that serves as the backend
|
||||||
|
for centillion.
|
||||||
|
|
||||||
|
## What the Search class does
|
||||||
|
|
||||||
|
The `Search` class has two roles:
|
||||||
|
- create (and update) the search index
|
||||||
|
- this also requires the `Search` class
|
||||||
|
to define the schema for storing documents
|
||||||
|
- run queries against the search index,
|
||||||
|
and package results up for Flask and Jinja
|
||||||
|
|
||||||
|
## Search class functions
|
||||||
|
|
||||||
|
The `Search` class defines several functions:
|
||||||
|
|
||||||
|
- `open_index()` creates the schema
|
||||||
|
|
||||||
|
- `add_issue()`, `add_md()`, `add_document()` have three diff method sigs and add diff types
|
||||||
|
of documents to the search index
|
||||||
|
|
||||||
|
- `update_all_issues()` or `update_all_md()` or `update_all_documents()` iterates over items
|
||||||
|
and determines whether each item needs to be updated in the search index
|
||||||
|
|
||||||
|
- `update_main_index()` - update the entire search index
|
||||||
|
- calls all three update_all methods
|
||||||
|
|
||||||
|
- `create_search_results()` - package things up for jinja
|
||||||
|
|
||||||
|
- `search()` - run the query, pass results to the jinja-packager
|
||||||
|
|
84
docs/index.md
Normal file
84
docs/index.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# Centillion
|
||||||
|
|
||||||
|
**centillion**: a pan-github-markdown-issues-google-docs search engine.
|
||||||
|
|
||||||
|
**a centillion**: a very large number consisting of a 1 with 303 zeros after it.
|
||||||
|
|
||||||
|
centillion is 3.03 log-times better than the googol.
|
||||||
|
|
||||||
|
## What is centillion
|
||||||
|
|
||||||
|
Centillion is a search engine built using [whoosh](https://whoosh.readthedocs.io/en/latest/intro.html),
|
||||||
|
a Python library for building search engines.
|
||||||
|
|
||||||
|
|
||||||
|
We define the types of documents centillion should index,
|
||||||
|
what info and how. Centillion then builds and
|
||||||
|
updates a search index. That's all done in `centillion_search.py`.
|
||||||
|
|
||||||
|
Centillion also provides a simple web frontend for running
|
||||||
|
queries against the search index. That's done using a Flask server
|
||||||
|
defined in `centillion.py`.
|
||||||
|
|
||||||
|
Centillion keeps it simple.
|
||||||
|
|
||||||
|
|
||||||
|
## Quickstart
|
||||||
|
|
||||||
|
Run centillion with a github access token API key set via
|
||||||
|
environment variable:
|
||||||
|
|
||||||
|
```
|
||||||
|
GITHUB_TOKEN="XXXXXXXX" python centillion.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This will start a Flask server, and you can view the minimal search engine
|
||||||
|
interface in your browser at <http://localhost:5000>.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Centillion configuration
|
||||||
|
|
||||||
|
`config_centillion.json` defines configuration variables
|
||||||
|
for centillion - namely, what to index, and how, and where.
|
||||||
|
|
||||||
|
### Flask configuration
|
||||||
|
|
||||||
|
`config_flask.py` defines configuration variables
|
||||||
|
used by flask, which controls the web frontend
|
||||||
|
for centillion.
|
||||||
|
|
||||||
|
## Control Panel/Rebuilding Search Index
|
||||||
|
|
||||||
|
To rebuild the search engine, visit the control panel route (`/control_panel`),
|
||||||
|
for example at <http://localhost:5000/control_panel>.
|
||||||
|
|
||||||
|
This allows you to rebuild the search engine index. The search index
|
||||||
|
is stored in the `search_index/` directory, and that directory
|
||||||
|
can be configured with centillion's configuration file.
|
||||||
|
|
||||||
|
The diff search index is faster to build, as it only
|
||||||
|
indexes documents that have been added since the last
|
||||||
|
new document was added to the search index.
|
||||||
|
|
||||||
|
The main search index is slower to build, as it will
|
||||||
|
re-index everything.
|
||||||
|
|
||||||
|
(Cron scripts? Threaded task that runs hourly?)
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
More on the details of how centillion works.
|
||||||
|
|
||||||
|
Under the hood, centillion uses flask and whoosh.
|
||||||
|
Flask builds and runs the web server.
|
||||||
|
Whoosh handles search requests and management
|
||||||
|
of the search index.
|
||||||
|
|
||||||
|
[Centillion Components](centillion_components.md)
|
||||||
|
|
||||||
|
[Centillion Flask](centillion_flask.md)
|
||||||
|
|
||||||
|
[Centillion Whoosh](centillion_whoosh.md)
|
||||||
|
|
||||||
|
|
@@ -31,3 +31,4 @@ Stateless
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
## work that is done
|
## work that is done: standalone
|
||||||
|
|
||||||
**Stage 1: index folder of markdown files** (done)
|
**Stage 1: index folder of markdown files** (done)
|
||||||
* See [markdown-search](https://git.charlesreid1.com/charlesreid1/markdown-search.git)
|
* See [markdown-search](https://git.charlesreid1.com/charlesreid1/markdown-search.git)
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
Needs work:
|
Needs work:
|
||||||
|
|
||||||
* More appropriate schema
|
* <s>More appropriate schema</s>
|
||||||
* Using more features (weights) plus pandoc filters for schema
|
* Using more features (weights) plus pandoc filters for schema
|
||||||
* Sqlalchemy (and hey waddya know safari books has it covered)
|
* Sqlalchemy (and hey waddya know safari books has it covered)
|
||||||
|
|
||||||
@@ -25,15 +25,16 @@ Needs work:
|
|||||||
* Main win here is uncovering metadata/linking/presentation issues
|
* Main win here is uncovering metadata/linking/presentation issues
|
||||||
|
|
||||||
Needs work:
|
Needs work:
|
||||||
- treat comments and issues as separate objects, fill out separate schema fields
|
- <s>treat comments and issues as separate objects, fill out separate schema fields
|
||||||
- map out and organize how the schema is updated to make it more flexible
|
- map out and organize how the schema is updated to make it more flexible
|
||||||
- configuration needs to enable user to specify organization+repos
|
- configuration needs to enable user to specify organization+repos</s>
|
||||||
|
|
||||||
```plain
|
```plain
|
||||||
{
|
{
|
||||||
"to_index" : {
|
"to_index" : [
|
||||||
"google" : "google-api-python-client",
|
"google/google-api-python-client",
|
||||||
"microsoft" : ["TypeCode","api-guidelines"]
|
"microsoft/TypeCode",
|
||||||
|
"microsoft/api-guielines"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -48,3 +49,4 @@ Needs work:
|
|||||||
* Use the google drive api (see simple-simon)
|
* Use the google drive api (see simple-simon)
|
||||||
* Main win is more uncovering of metadata issues, identifying
|
* Main win is more uncovering of metadata issues, identifying
|
||||||
big-picture issues for centillion
|
big-picture issues for centillion
|
||||||
|
|
48
docs/workinprogress.md
Normal file
48
docs/workinprogress.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Components
|
||||||
|
|
||||||
|
The components of centillion are as follows:
|
||||||
|
- Flask application, which creates a Search object and uses it to search index
|
||||||
|
- Search object, which allows you to create/update/search an index
|
||||||
|
|
||||||
|
## Routes layout
|
||||||
|
|
||||||
|
Centillion flask app routes:
|
||||||
|
|
||||||
|
- `/home`
|
||||||
|
- if not logged in, landing page
|
||||||
|
- if logged in, redirect to search
|
||||||
|
- `/search`
|
||||||
|
- `/main_index_update`
|
||||||
|
- update main index, all docs period
|
||||||
|
|
||||||
|
## Functions layout
|
||||||
|
|
||||||
|
Centillion Search class functions:
|
||||||
|
|
||||||
|
- `open_index()` creates the schema
|
||||||
|
|
||||||
|
- `add_issue()`, `add_md()`, `add_document()` have three diff method sigs and add diff types
|
||||||
|
of documents to the search index
|
||||||
|
|
||||||
|
- `update_all_issues()` or `update_all_md()` or `update_all_documents()` iterates over items
|
||||||
|
and determines whether each item needs to be updated in the search index
|
||||||
|
|
||||||
|
- `update_main_index()` - update the entire search index
|
||||||
|
- calls all three update_all methods
|
||||||
|
|
||||||
|
- `create_search_results()` - package things up for jinja
|
||||||
|
|
||||||
|
- `search()` - run the query, pass results to the jinja-packager
|
||||||
|
|
||||||
|
Nice to have but focus on it later:
|
||||||
|
- update diff search index (what's been added since last index time)
|
||||||
|
- max index time
|
||||||
|
|
||||||
|
|
||||||
|
## Files layout
|
||||||
|
|
||||||
|
Schema definition:
|
||||||
|
* include a "kind" or "class" to group objects
|
||||||
|
* can provide different searches of different collections
|
||||||
|
* eventually can provide user with checkboxes
|
||||||
|
|
BIN
img/ss.png
Normal file
BIN
img/ss.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 356 KiB |
19
install_pandoc.sh
Executable file
19
install_pandoc.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# for ubuntu
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "This script should be run as root."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
OFILE="/tmp/pandoc.deb"
|
||||||
|
curl -L https://github.com/jgm/pandoc/releases/download/2.2.2.1/pandoc-2.2.2.1-1-amd64.deb -o ${OFILE}
|
||||||
|
dpkg -i ${OFILE}
|
||||||
|
rm -f ${OFILE}
|
||||||
|
|
||||||
|
|
1
mkdocs-material
Submodule
1
mkdocs-material
Submodule
Submodule mkdocs-material added at 6569122bb1
@@ -9,3 +9,4 @@ PyGithub>=1.39
|
|||||||
pypandoc>=1.4
|
pypandoc>=1.4
|
||||||
requests>=2.19
|
requests>=2.19
|
||||||
pandoc>=1.0
|
pandoc>=1.0
|
||||||
|
flask-dance>=1.0.0
|
||||||
|
6
static/bootstrap.min.css
vendored
Normal file
6
static/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
static/bootstrap.min.js
vendored
Normal file
7
static/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
static/centillion_black.png
Normal file
BIN
static/centillion_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
static/centillion_white.png
Normal file
BIN
static/centillion_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
static/centillion_xparent.png
Normal file
BIN
static/centillion_xparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
2
static/jquery.min.js
vendored
Normal file
2
static/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,3 +1,45 @@
|
|||||||
|
span.badge {
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.badgelinks, a.badgelinks:hover {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.list-group {
|
||||||
|
border: 1px solid rgba(86,61,124,.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
li.list-group-item {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
/*padding: 20px 10px;*/
|
||||||
|
margin-bottom: -1px;
|
||||||
|
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.search-group-item {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
padding: 0px;
|
||||||
|
margin-bottom: -1px;
|
||||||
|
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.url {
|
||||||
|
background-color: rgba(86,61,124,.15);
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************/
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
@@ -56,7 +98,7 @@ table {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.info, .last-searches {
|
.info, .last-searches {
|
||||||
color: gray;
|
color: gray;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-family: Arial, serif;
|
font-family: Arial, serif;
|
||||||
|
108
templates/controlpanel.html
Executable file
108
templates/controlpanel.html
Executable file
@@ -0,0 +1,108 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages() %}
|
||||||
|
{% if messages %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="alert alert-success alert-dismissible">
|
||||||
|
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||||
|
<ul class=flashes>
|
||||||
|
{% for message in messages %}
|
||||||
|
<li>{{ message }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<center>
|
||||||
|
<a href="{{ url_for('search')}}?query=&fields=">
|
||||||
|
<img src="{{ url_for('static', filename='centillion_white.png') }}">
|
||||||
|
</a>
|
||||||
|
{% if config['TAGLINE'] %}
|
||||||
|
<h2><a href="{{ url_for('search')}}?query=&fields=">
|
||||||
|
{{config['TAGLINE']}}
|
||||||
|
</a></h2>
|
||||||
|
{% endif %}
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if config['zzzTAGLINE'] %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col12sm">
|
||||||
|
<center>
|
||||||
|
<h2><a href="{{ url_for('search')}}?query=&fields=">
|
||||||
|
{{config['TAGLINE']}}
|
||||||
|
</a></h2>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
{# update main search index #}
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">
|
||||||
|
Update Main Search Index
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<p class="panel-text">Re-index <i>every</i> document in the
|
||||||
|
remote collection in the search index. <b>Warning: this operation may take a while.</b>
|
||||||
|
<p/> <p>
|
||||||
|
<a href="{{ url_for('update_index') }}" class="btn btn-large btn-danger">Update Main Index</a>
|
||||||
|
<p/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# update diff search index #}
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">
|
||||||
|
Update Diff Search Index
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<p class="panel-text">Diff search index only re-indexes documents created after the last
|
||||||
|
search index update. <b>Not currently implemented.</b>
|
||||||
|
<p/> <p>
|
||||||
|
<a href="#" class="btn btn-large disabled btn-danger">Update Diff Index</a>
|
||||||
|
<p/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
@@ -1,10 +1,12 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<title>Markdown Search</title>
|
<title>Markdown Search</title>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='github-markdown.css') }}">
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='github-markdown.css') }}">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap.min.css') }}">
|
||||||
|
|
||||||
|
<script src="{{ url_for('static', filename='jquery.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='bootstrap.min.js') }}"></script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% for message in get_flashed_messages() %}
|
|
||||||
<div class="flash">{{ message }}</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% block body %}{% endblock %}
|
{% block body %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,62 +1,173 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1><a href="{{ url_for('search')}}?query=&fields=">Search directory: {{ config.MARKDOWN_FILES_DIR }}</a></h1>
|
|
||||||
<a class="index" href="{{ url_for('update_index')}}">[update index]</a>
|
|
||||||
<a class="index" href="{{ url_for('update_index')}}?rebuild=True">[rebuild index]</a>
|
<div class="container">
|
||||||
<form action="{{ url_for('search') }}" name="search">
|
|
||||||
<input type="text" name="query" value="{{ query }}">
|
{#
|
||||||
<input type="submit" value="search">
|
banner image
|
||||||
<a href="{{ url_for('search')}}?query=&fields=">[clear]</a>
|
#}
|
||||||
</form>
|
<div class="row">
|
||||||
<table cellspacing="3">
|
<div class="col12sm">
|
||||||
|
<center>
|
||||||
|
<a href="{{ url_for('search')}}?query=&fields=">
|
||||||
|
<img src="{{ url_for('static', filename='centillion_white.png') }}">
|
||||||
|
</a>
|
||||||
|
{#
|
||||||
|
need a tag line
|
||||||
|
#}
|
||||||
|
{% if config['TAGLINE'] %}
|
||||||
|
<h2><a href="{{ url_for('search')}}?query=&fields=">
|
||||||
|
{{config['TAGLINE']}}
|
||||||
|
</a></h2>
|
||||||
|
{% endif %}
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<center>
|
||||||
|
<form action="{{ url_for('search') }}" name="search">
|
||||||
|
<input type="text" name="query" value="{{ query }}"> <br />
|
||||||
|
<button type="submit" style="font-size: 20px; padding: 10px; padding-left: 50px; padding-right: 50px;"
|
||||||
|
value="search" class="btn btn-primary">Search</button>
|
||||||
|
<br />
|
||||||
|
<a href="{{ url_for('search')}}?query=&fields=">[clear all results]</a>
|
||||||
|
</form>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
{% if directories %}
|
{% if directories %}
|
||||||
<tr>
|
<div class="col-xs-12 info directories-cloud">
|
||||||
<td class="directories-cloud">File directories: 
|
<b>File directories:</b>
|
||||||
{% for d in directories %}
|
{% for d in directories %}
|
||||||
<a href="{{url_for('search')}}?query={{d|trim}}&fields=filename">{{d|trim}}</a>
|
<a href="{{url_for('search')}}?query={{d|trim}}&fields=filename">{{d|trim}}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if config['SHOW_PARSED_QUERY']%}
|
|
||||||
<tr>
|
<ul class="list-group">
|
||||||
<td class="info">Parsed query: {{ parsed_query }}</td>
|
|
||||||
</tr>
|
{% if config['SHOW_PARSED_QUERY'] and parsed_query %}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 info">
|
||||||
|
<b>Parsed query:</b> {{ parsed_query }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
|
||||||
<td class="info">FOUND {{ entries | length }} results of {{total}} documents</td>
|
{% if parsed_query %}
|
||||||
</tr>
|
<li class="list-group-item">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 info">
|
||||||
|
<b>Found:</b> <span class="badge">{{entries|length}}</span> results
|
||||||
|
out of <span class="badge">{{totals["total"]}}</span> total items indexed
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 info">
|
||||||
|
<b>Indexing:</b> <span class="badge">{{totals["documents"]}}</span> Google Documents,
|
||||||
|
<span class="badge">{{totals["issues"]}}</span> Github issues,
|
||||||
|
<span class="badge">{{totals["markdown"]}}</span> markdown files.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
{% for e in entries %}
|
{% for e in entries %}
|
||||||
<tr>
|
<li class="search-group-item">
|
||||||
<td class="search-result">
|
|
||||||
<!--
|
|
||||||
<div class="path"><a href='{{ url_for("open_file")}}?path={{e.path|urlencode}}&query={{query}}&fields={{fields}}'>{{e.path}}</a>score: {{'%d' % e.score}}</div>
|
|
||||||
-->
|
|
||||||
<div class="url">
|
<div class="url">
|
||||||
{% if e.is_comment %}
|
{% if e.kind=="gdoc" %}
|
||||||
<b>Comment</b> <a href='{{e.url}}'>(comment link)</a>
|
<b>Google Drive File:</b>
|
||||||
on issue <a href='{{e.issue_url}}'>{{e.issue_title}}</a>
|
<a href='{{e.url}}'>{{e.title}}</a>
|
||||||
in repo <a href='{{e.repo_url}}'>dcppc/{{e.repo_name}}</a>
|
(Owner: {{e.owner_name}}, {{e.owner_email}})
|
||||||
<br />
|
|
||||||
{% else %}
|
{% elif e.kind=="issue" %}
|
||||||
<b>Issue</b> <a href='{{e.issue_url}}'>{{e.issue_title}}</a>
|
<b>Issue:</b>
|
||||||
in repo <a href='{{e.repo_url}}'>dcppc/{{e.repo_name}}</a>
|
<a href='{{e.url}}'>{{e.title}}</a>
|
||||||
<br />
|
{% if e.github_user %}
|
||||||
|
opened by <a href='https://github.com/{{e.github_user}}'>@{{e.github_user}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<br/>
|
||||||
|
<b>Repository:</b> <a href='{{e.repo_url}}'>{{e.repo_name}}</a>
|
||||||
|
|
||||||
|
{% elif e.kind=="markdown" %}
|
||||||
|
<b>Markdown:</b>
|
||||||
|
<a href='{{e.url}}'>{{e.title}}</a>
|
||||||
|
<br/>
|
||||||
|
<b>Repository:</b> <a href='{{e.repo_url}}'>{{e.repo_name}}</a>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<b>Item:</b> (<a href='{{e.url}}'>link</a>)
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
<br />
|
||||||
score: {{'%d' % e.score}}
|
score: {{'%d' % e.score}}
|
||||||
</div>
|
</div>
|
||||||
<div class="markdown-body">{{ e.content_highlight|safe}}</div>
|
<div class="markdown-body">{{ e.content_highlight|safe}}</div>
|
||||||
</td>
|
|
||||||
</tr>
|
</li>
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<div class="last-searches">Last searches: <br/>
|
|
||||||
{% for s in last_searches %}
|
|
||||||
<span><a href="{{url_for('search')}}?{{s}}">{{s}}</a></span>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
|
||||||
More info can be found in the <a href="https://github.com/BernhardWenzel/markdown-search">README.md file</a>
|
<div class="container">
|
||||||
</p>
|
<div class="row">
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
|
{% if config['FOOTER_REPO_NAME'] %}
|
||||||
|
{% if config['FOOTER_REPO_ORG'] %}
|
||||||
|
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 info">
|
||||||
|
More information about {{config['FOOTER_REPO_NAME']}} can be found
|
||||||
|
in the <a href="https://github.com/{{config['FOOTER_REPO_ORG']}}/{{config['FOOTER_REPO_NAME']}}">{{config['FOOTER_REPO_ORG']}}/{{config['FOOTER_REPO_NAME']}}</a>
|
||||||
|
repository on Github.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user