-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
560 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from cryptoadvance.specter.services.callbacks import Callback | ||
|
||
|
||
class my_callback(Callback): | ||
id = "my_callback" |
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,53 @@ | ||
[ | ||
{ | ||
"readlater": "no", | ||
"annotations": [], | ||
"tags": "no_tag", | ||
"comments": [], | ||
"shared": "yes", | ||
"url": "http://a16z.com/2014/05/30/selling-saas-products-dont-sell-themselves/", | ||
"desc": "\"Some people think the sales force’s job is to communicate value to customers.They’re wrong.\" @mdcranney : http://t.co/t146HVhuuT via @a16z", | ||
"title": "If SaaS Products Sell Themselves, Why Do We Need Sales? | Andreessen Horowitz" | ||
}, | ||
{ | ||
"readlater": "no", | ||
"annotations": [], | ||
"tags": "bitcoin,video,education", | ||
"comments": [], | ||
"shared": "yes", | ||
"url": "https://www.youtube.com/watch?v=MhmxpfA7_Ag", | ||
"desc": "", | ||
"title": "Bitcoin Decrypted Part III: Social theory aspects - YouTube" | ||
}, | ||
{ | ||
"readlater": "no", | ||
"annotations": [], | ||
"tags": "bitcoin,video,education", | ||
"comments": [], | ||
"shared": "yes", | ||
"url": "https://www.youtube.com/watch?v=HvfO5u4ImAU", | ||
"desc": "", | ||
"title": "Bitcoin Decrypted Part II: Technical aspects (updated) - YouTube" | ||
}, | ||
{ | ||
"readlater": "no", | ||
"annotations": [], | ||
"tags": "bitcoin,video,education", | ||
"comments": [], | ||
"shared": "yes", | ||
"url": "https://www.youtube.com/watch?v=O4yrvRxFEWs", | ||
"desc": "", | ||
"title": "Bitcoin Decrypted Part I: Context and overview - YouTube" | ||
}, | ||
{ | ||
"readlater": "no", | ||
"annotations": [], | ||
"tags": "no_tag", | ||
"comments": [], | ||
"shared": "yes", | ||
"url": "http://t.co/Ub9XKrbInU", | ||
"desc": "“You’ve been around long enough to know there won’t be any calm periods” @tomheon: Speeding Up Your Engineering Org http://t.co/Ub9XKrbInU", | ||
"title": "“You’ve been around long enoug" | ||
} | ||
] | ||
|
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,40 @@ | ||
import typing | ||
import strawberry | ||
from typing import List | ||
import json | ||
import os | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@strawberry.type | ||
class Bookmark: | ||
url: str | ||
desc: str | ||
readlater: str | ||
annotations: List[str] | ||
tags: str | ||
comments: List[str] | ||
shared: str | ||
title: str | ||
|
||
|
||
def get_bookmarks() -> List[Bookmark]: | ||
logger.info("CALLING get_bookmarks!!") | ||
with open("src/cryptoadvance/specterext/devhelp/data.json") as json_file: | ||
data = json.load(json_file) | ||
listOfBookmarks = [] | ||
for item in data: | ||
b = Bookmark( | ||
url=item["url"], | ||
desc=item["desc"], | ||
readlater=item["readlater"], | ||
annotations=[], # fixme | ||
tags=item["tags"], | ||
comments=item["comments"], | ||
shared=item["shared"], | ||
title=item["title"], | ||
) | ||
listOfBookmarks.append(b) | ||
return listOfBookmarks |
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,9 @@ | ||
Inspired by strawberry and the small [POC](https://github.com/k9ert/nomstr) | ||
|
||
# potential issues | ||
|
||
There might be a dependency conflict: | ||
``` | ||
typing_extensions<5.0.0,>=3.7.4 (from strawberry-graphql==0.155.2->-r requirements.in (line 35)) | ||
typing-extensions<4.0,>=3.7 (from hwi==2.1.1->-r requirements.in (line 11)) | ||
``` |
Empty file.
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,15 @@ | ||
from cryptoadvance.specter.services.callbacks import Callback | ||
|
||
|
||
class create_graphql_schema(Callback): | ||
""" | ||
Gives you the ability to add to the GraphQL schema | ||
example: | ||
def callback_create_graphql_schema(self, field_list): | ||
# Add your fields to the Schema like this:: | ||
field_list.append(strawberry.field(name="bookmarks", resolver=get_bookmarks)) | ||
return field_list | ||
""" | ||
|
||
id = "create_graphql_schema" | ||
return_style = "middleware" |
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,31 @@ | ||
""" | ||
Here Configuration of your Extension takes place | ||
""" | ||
|
||
import os | ||
|
||
|
||
def _get_bool_env_var(varname, default=None): | ||
|
||
value = os.environ.get(varname, default) | ||
|
||
if value is None: | ||
return False | ||
elif isinstance(value, str) and value.lower() == "false": | ||
return False | ||
elif bool(value) is False: | ||
return False | ||
else: | ||
return bool(value) | ||
|
||
|
||
class BaseConfig: | ||
"""This is a extension-based Config which is used as Base""" | ||
|
||
SPECTER_GRAPHQL_ACTIVE = _get_bool_env_var("SPECTER_GRAPHQL_ACTIVE", "True") | ||
|
||
|
||
class ProductionConfig(BaseConfig): | ||
"""This is a extension-based Config for Production""" | ||
|
||
SPECTER_GRAPHQL_ACTIVE = _get_bool_env_var("SPECTER_GRAPHQL_ACTIVE", "False") |
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,73 @@ | ||
import logging | ||
from flask import redirect, render_template, request, url_for, flash | ||
from flask import current_app as app | ||
from flask_login import login_required, current_user | ||
from strawberry.flask.views import GraphQLView | ||
|
||
from cryptoadvance.specter.specter import Specter | ||
from cryptoadvance.specter.services.controller import user_secret_decrypted_required | ||
from cryptoadvance.specter.user import User | ||
from cryptoadvance.specter.wallet import Wallet | ||
from .service import GraphqlService | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
graphql_endpoint = GraphqlService.blueprint | ||
|
||
|
||
def ext() -> GraphqlService: | ||
"""convenience for getting the extension-object""" | ||
return app.specter.ext["graphql"] | ||
|
||
|
||
def specter() -> Specter: | ||
"""convenience for getting the specter-object""" | ||
return app.specter | ||
|
||
|
||
# This endpoint is added dynamically in service.py | ||
# @graphql_endpoint.route("/graphql", methods=["GET", "POST"]) | ||
# @app.csrf.exempt | ||
# def index(): | ||
# view_func = GraphQLView.as_view("graphql_view", schema=schema2) | ||
# return view_func() | ||
|
||
|
||
@graphql_endpoint.route("/") | ||
@login_required | ||
def index(): | ||
return render_template( | ||
"graphql/index.jinja", | ||
) | ||
|
||
|
||
@graphql_endpoint.route("/transactions") | ||
@login_required | ||
def schema(): | ||
# The wallet currently configured for ongoing autowithdrawals | ||
|
||
return render_template( | ||
"graphql/schema.jinja", | ||
) | ||
|
||
|
||
@graphql_endpoint.route("/settings", methods=["GET"]) | ||
@login_required | ||
def settings_get(): | ||
|
||
return render_template( | ||
"graphql/settings.jinja", | ||
) | ||
|
||
|
||
@graphql_endpoint.route("/settings", methods=["POST"]) | ||
@login_required | ||
def settings_post(): | ||
show_menu = request.form["show_menu"] | ||
user = app.specter.user_manager.get_user() | ||
if show_menu == "yes": | ||
user.add_service(GraphqlService.id) | ||
else: | ||
user.remove_service(GraphqlService.id) | ||
return redirect(url_for(f"{ GraphqlService.get_blueprint_name()}.settings_get")) |
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,30 @@ | ||
from flask import current_app as app | ||
from cryptoadvance.specter.managers.user_manager import UserManager | ||
|
||
import typing | ||
import strawberry | ||
from typing import List | ||
import json | ||
import os | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@strawberry.type | ||
class User: | ||
username: str | ||
|
||
|
||
def get_users() -> List[User]: | ||
um: UserManager = app.specter.user_manager | ||
um.users | ||
listOfUsers = [] | ||
for item in um.users: | ||
u = User(username=item.username) | ||
listOfUsers.append(u) | ||
return listOfUsers | ||
|
||
|
||
def create_fields(): | ||
return [strawberry.field(name="users", resolver=get_users)] |
Oops, something went wrong.