Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move gallery to source code and update distribution manifest
- Loading branch information
Showing
28 changed files
with
295 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
gallery | ||
======= | ||
|
||
.. automodule:: zelfred.gallery | ||
:members: | ||
|
||
sub packages and modules | ||
------------------------ | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
e01_random_password_generator <e01_random_password_generator> | ||
e02_calculate_file_checksum <e02_calculate_file_checksum> | ||
e03_select_item_using_fuzzy_match <e03_select_item_using_fuzzy_match> | ||
e04_google_search_with_suggestion <e04_google_search_with_suggestion> | ||
e05_search_google_chrome_bookmark <e05_search_google_chrome_bookmark> | ||
e06_folder_and_file_search <e06_folder_and_file_search> | ||
e07_password_book <e07_password_book> | ||
e08_refresh_cache_v1 <e08_refresh_cache_v1> | ||
e09_refresh_cache_v2 <e09_refresh_cache_v2> | ||
e09_refresh_cache_v3 <e09_refresh_cache_v3> | ||
e10_json_formatter <e10_json_formatter> | ||
|
5 changes: 5 additions & 0 deletions
5
docs/source/zelfred/gallery/e01_random_password_generator.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e01_random_password_generator | ||
============================= | ||
|
||
.. automodule:: zelfred.gallery.e01_random_password_generator | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e02_calculate_file_checksum | ||
=========================== | ||
|
||
.. automodule:: zelfred.gallery.e02_calculate_file_checksum | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/zelfred/gallery/e03_select_item_using_fuzzy_match.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e03_select_item_using_fuzzy_match | ||
================================= | ||
|
||
.. automodule:: zelfred.gallery.e03_select_item_using_fuzzy_match | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/zelfred/gallery/e04_google_search_with_suggestion.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e04_google_search_with_suggestion | ||
================================= | ||
|
||
.. automodule:: zelfred.gallery.e04_google_search_with_suggestion | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/zelfred/gallery/e05_search_google_chrome_bookmark.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e05_search_google_chrome_bookmark | ||
================================= | ||
|
||
.. automodule:: zelfred.gallery.e05_search_google_chrome_bookmark | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e06_folder_and_file_search | ||
========================== | ||
|
||
.. automodule:: zelfred.gallery.e06_folder_and_file_search | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e07_password_book | ||
================= | ||
|
||
.. automodule:: zelfred.gallery.e07_password_book | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e08_refresh_cache_v1 | ||
==================== | ||
|
||
.. automodule:: zelfred.gallery.e08_refresh_cache_v1 | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e09_refresh_cache_v2 | ||
==================== | ||
|
||
.. automodule:: zelfred.gallery.e09_refresh_cache_v2 | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e09_refresh_cache_v3 | ||
==================== | ||
|
||
.. automodule:: zelfred.gallery.e09_refresh_cache_v3 | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
e10_json_formatter | ||
================== | ||
|
||
.. automodule:: zelfred.gallery.e10_json_formatter | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Feature: | ||
No matter what user entered, always return a random value between 1 and 100. | ||
And this value is based on cache that won't change while user is typing. | ||
However, we want to provide a way to refresh the value. User can type "!~", | ||
then the value will be immediately refreshed, and the "!~" will be removed | ||
automatically. | ||
Difficulty: Medium | ||
Dependencies: NA | ||
Demo: https://asciinema.org/a/631325 | ||
""" | ||
|
||
import random | ||
|
||
import zelfred.api as zf | ||
|
||
|
||
class Cache: | ||
def __init__(self): | ||
self.value = None | ||
|
||
|
||
cache = Cache() | ||
|
||
|
||
def handler(query: str, ui: zf.UI): | ||
""" | ||
The handler is the core of a Zelfred App. It's a user-defined function | ||
that takes the entered query and the UI object as inputs and returns | ||
a list of items to render. | ||
""" | ||
# if query is for refresh value | ||
if "!~" in query: | ||
# refresh the value | ||
cache.value = random.randint(1, 100) | ||
# remove the "!~" from the query in the UI | ||
ui.line_editor.press_backspace(2) | ||
return [ | ||
zf.Item( | ||
title=f"Value {cache.value}", | ||
subtitle=f"Type !~ to refresh the value", | ||
) | ||
] | ||
# otherwise, always return a random value, and cache it | ||
else: | ||
if cache.value is None: | ||
cache.value = random.randint(1, 100) | ||
return [ | ||
zf.Item( | ||
title=f"Value {cache.value}", | ||
subtitle=f"Type !~ to refresh the value", | ||
) | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
# reset the debugger and enable it | ||
zf.debugger.reset() | ||
zf.debugger.enable() | ||
|
||
# create the UI and run it | ||
ui = zf.UI(handler=handler, capture_error=True) | ||
ui.run() |
Oops, something went wrong.