Skip to content

Commit

Permalink
Full working version, Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
bantya committed Feb 6, 2019
1 parent 46aeb49 commit 7e7d1bc
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 67 deletions.
144 changes: 121 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@
This is Zealous, a plugin for the
[Keypirinha](http://keypirinha.com) launcher.

**TODO:** write a brief description of this package. Optionally add a
screenshot.
This plugin is developed to facilitate the offline documentation search using the awesome Zeal app.

| ![Zealous usage](./imgs/2019-02-07_00-27-02.gif "Zealous usage") |
| :-: |
| *Zealous Usage* |


## Background

[Zeal](https://zealdocs.org) is one of the best offline documentation search tool available today. Its docsets are made available by [Dash](https://kapeli.com).

| ![Zeal App](./imgs/2019-02-07_00-21-47.png "Zeal App") |
| :-: |
| *Zeal App for Windows* |

It provides the ability to install docsets for almost all of the mainstream languages, tools, toolsets and everything that can have its own docset. It can filter the results as per the result type (highlighted above 👆).


## Download

**TODO:** indicate where the latest `.keypirinha-package` file can be
downloaded. For example a URL to the `releases` list like:
https://github.com/bantya/Keypirinha-Zealous/releases
Download the latest plugin file from [here](https://github.com/bantya/Keypirinha-Zealous/releases).


## Install

Once the `Zealous.keypirinha-package` file is installed,
Once the `Zealous.keypirinha-package` file is downloaded,
move it to the `InstalledPackage` folder located at:

* `Keypirinha\portable\Profile\InstalledPackages` in **Portable mode**
Expand All @@ -25,46 +37,132 @@ move it to the `InstalledPackage` folder located at:
`C:\Users\%USERNAME%\AppData\Roaming\Keypirinha\InstalledPackages`)


## Configuration

1. Open the Zealous config file.

| ![Keypirinha configuration](./imgs/2019-02-06_23-59-01.png "Keypirinha configuration") |
| :-: |
| *Zealous configuration settings.* |

2. The **main** section is necessary if you installed the Zeal to non-default location. You will have to provide the **Zeal install path** and **the docsets path** in this case.

The **result** is the count of how many entries to be fetched from the Zeal docsets. **Default: 50**

3. Add the entries to the **docs** section.
* The syntax for the **docs** entry should be:
```
[Docset mnemonic] = [The zeal docset search phrase]
e.g.
php = php
ld = laravel
js = javascript
sql = mysql
py = python
```

4. Add the entries to the **types** section.

Which can be seen as highlighted part in Zeal App image above 👆.

The types can be found [here](https://kapeli.com/docsets#supportedentrytypes).

* The syntax for the **types** entry should be:
```
[Type mnemonic] = [The zeal docset types]
e.g.
g = Guide
h = Helper
sec = Section
key = Keyword
```

* There are some quirks. Some dataset entrytype (as Zeal calls it) are not as exact as the specified in [here](https://kapeli.com/docsets#supportedentrytypes).

Especially, **php** along with some other docsets, does not follow the rule. So to make it play even with such docsets, we have to add the supported non-exact result types also.
```
e.g.
f = Function,func
m = Method,clm
c = Class,cl
p = Property,instp
t = Type,tdef
mc = Macro,macro
```
* All the fields in the above syntax are REQUIRED.

| ![Zealous config file](./imgs/2019-02-07_00-23-15.png "Zealous config file") |
| :-: |
| *Zealous config file.* |

## Usage

**TODO:** list the items, if any, inserted to the Catalog by the plugin(s) of
this package. Some plugins only make suggestions, in which case a description of
what kind of suggestions are to be expected by the user may help.
Invoke Keypirinha and put the terms as follows.
* The syntax for the usage should be:
```
[Docset mnemonic] [Result type]? [Search term]
e.g.
php explode -> searches 'explode' in PHP docset
ld g auth -> searches 'auth' of 'Guide' type in Laravel docset
js key ...obj -> searches '...obj' of 'Keyword' type in Javascipt docset
```
* Though the usage of [Result type] is optional, using it filters the results only to that type.

| ![Zealous simple search](./imgs/2019-02-07_00-23-49.png "Zealous simple search") |
| :-: |
| *Simple search.* |

| ![Zealous simple search](./imgs/2019-02-07_00-24-18.png "Zealous simple search") |
| :-: |
| *Advanced search with type provided.* |


## Change Log

**TODO:** describe notable changes for each release. Below is a template for
version 1.0.
### v1.0.0

### v1.0
* Bumped version to v1.0.0
* Full working release.
* Added advanced searching ability.
* Updated the README.

* Added foo item
* Fixed bug that was doing bad things when item "bar" was selected
### v0.0.2 (Unreleased)

* Added docset db search.
* Added simple searching.

### v0.0.1 (Unreleased)

* First working draft

## License

**TODO:** recommended section. Below is an example that goes with the default
LICENSE file (MIT license). Do not forget to add your name in the `LICENSE`
file!
## License

This package is distributed under the terms of the MIT license.
This package is distributed under the terms of the **MIT license**.


## Credits

**TODO:** optional section.
_Do some work and add your name here!_


## Contribute

**TODO:** optional section. Below is a template example, based on the one found
in Keypirinha's Packages repository.

This is how to contribute:
1. Check for open issues or open a fresh issue to start a discussion around a
feature idea or a bug.
2. Fork this repository on GitHub to start making your changes to the **dev**
branch.
3. Send a pull request.
4. Add yourself to the *Contributors* section below (or create it if needed)!

## And what?

Thanks to all.
Binary file added imgs/2019-02-06_23-59-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/2019-02-07_00-21-47.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/2019-02-07_00-23-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/2019-02-07_00-23-49.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/2019-02-07_00-24-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/2019-02-07_00-27-02.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 22 additions & 17 deletions src/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from sqlite3 import Error

def create_connection(db_file):
""" create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
"""
try:
conn = sqlite3.connect(db_file)
return conn
Expand All @@ -15,19 +10,29 @@ def create_connection(db_file):

return None

def get_names(db_file, term):
"""
Query all rows in the tasks table
:param conn: the Connection object
:return:
"""

def get_names(db_file, term, count):
conn = create_connection(db_file)
cur = conn.cursor()
cur.execute('SELECT name FROM searchIndex WHERE name LIKE ? LIMIT ?', (
'%' + term + '%',
count,
))

return cur.fetchall()


def get_types_names(db_file, term, count, type, type2=None):
type = ''.join(type)
conn = create_connection(db_file)
cur = conn.cursor()
# cur.execute('SELECT name, type FROM searchIndex LIMIT 50')
cur.execute('SELECT name FROM searchIndex WHERE name LIKE ? LIMIT 50', (term + '%',))
# query = 'SELECT name FROM searchIndex WHERE name LIKE ' + term + '%'
# cur.execute(query)
# print(query)
if type2 is None:
cur.execute(
'SELECT name FROM searchIndex WHERE type = ? AND name LIKE ? LIMIT ?',
(type, '%' + term + '%', count))
else:
cur.execute(
'SELECT name FROM searchIndex WHERE type IN (?, ?) AND name LIKE ? LIMIT ?',
(type, type2, '%' + term + '%', count))

# return cur.fetchone()
return cur.fetchall()
37 changes: 26 additions & 11 deletions src/zealous.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,41 @@
# More info at http://keypirinha.com
#

# NOTE TO PLUGIN DEVELOPER:
# * This file may be removed from the package if no plugin requires
# configuration
# * The [main] section below is an example and not mandatory, however it is good
# practice to keep the [var] and [env] sections, as well as their respective
# comments
# * This comment block may be removed!

[main]
# Plugin's main configuration section
# path = "C:\Program Files\Zeal"
# docset_path = "C:\Users\thAKare\AppData\Local\Zeal\Zeal\docsets"
# path
# The path to the zeal executable
# default = "C:\Program Files\Zeal"
#
# docset_path
# The zeal docsets path
# default = "C:\Users\USERNAME\AppData\Local\Zeal\Zeal\docsets"
#
# results
# The total results count
# default = 50

[docs]
# The zeal docs list
# e.g.
#
# Syntax
# keyword = zeal doc name
#
# e.g.
# ap = apache
# ng = nginx

[types]
# The entry types list
# Check here for reference: https://kapeli.com/docsets#supportedentrytypes
#
# Syntax:
# keyword = entry type
#
# e.g.
# g = guide
# f = functions

[var]
# As in every Keypirinha's configuration file, you may optionally include a
# [var] section to declare variables that you want to reuse anywhere else in
Expand Down
Loading

0 comments on commit 7e7d1bc

Please sign in to comment.