CDN¶
For quick reference when prototyping you can use the CDN package.
To use a CDN class it must be imported.
from domonic.CDN import *
Or just classes you need…
from domonic.CDN import CDN_JS, CDN_CSS
CDN_JS¶
script(_src=CDN_JS.JQUERY_3_5_1)
CDN_CSS¶
classless_css = link(_rel="stylesheet", _href=CDN_CSS.WATER_LATEST)
currently constants exist for:
BOOTSTRAP_5_ALPHA
BOOTSTRAP_4
MARX
MVP
WATER_LATEST
BALLOON
THREE_DOTS_0_2_0
MILLIGRAM_1_3_0
X3DOM
FONTAWESOME_5_7_1
MDI_5_4_55
CDN_IMG¶
CDN_IMG has a placeholder service.
# to change it. do this...
CDN_IMG.PLACEHOLDER_SERVICE = "placebear.com/g"
img(_src=CDN_IMG.PLACEHOLDER(300,100))
# optional seperator if the site uses x instead of slash between dimensions
img(_src=CDN_IMG.PLACEHOLDER(300,100,'x'))
# there’s tons to pick from. (NOT ALL ARE HTTPS):
https://dummyimage.com/420x320/ff7f7f/333333.png&text=Sample
https://fakeimg.pl/420x320/ff0000,128/333333,255/?text=Sample&font=lobster
https://via.placeholder.com/420x320/ff7f7f/333333?text=Sample
domonic.CDN¶
For quick reference when prototyping you can use the CDN package. (Don’t rely on a CDN package for production code. wget a local copy.)
TODO - integrity/cross origin/module?
- class domonic.CDN.CDN_CSS[source]
Preferably use version numbers if available. use LATEST if it always gets the latest
- BALLOON: str = 'https://unpkg.com/balloon-css/balloon.min.css'
- BOOTSTRAP_4: str = 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'
- BOOTSTRAP_5_ALPHA: str = 'https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js'
- FONTAWESOME_5_7_1: str = 'https://use.fontawesome.com/releases/v5.7.1/css/all.css'
- MARX: str = 'https://unpkg.com/marx-css/css/marx.min.css'
- MDI_5_4_55: str = 'https://cdn.materialdesignicons.com/5.4.55/css/materialdesignicons.min.css'
- MILLIGRAM_1_3_0: str = 'https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.css'
- MVP: str = 'https://unpkg.com/mvp.css'
- SIMPLE: str = 'https://cdn.simplecss.org/simple.min.css'
- TAILWIND_2_2_15: str = 'https://unpkg.com/tailwindcss@^2.2.15/dist/tailwind.min.css'
- THREE_DOTS_0_2_0: str = 'https://cdnjs.cloudflare.com/ajax/libs/three-dots/0.2.0/three-dots.min.css'
- WATER_LATEST: str = 'https://cdn.jsdelivr.net/gh/kognise/water.css@latest/water.min.css'
- X3DOM: str = 'https://www.x3dom.org/download/x3dom.css'
- class domonic.CDN.CDN_IMG[source]
CDN images
- static PLACEHOLDER(width: int = 100, height: int = 100, HTTP: str = '', seperator: str = '/') str [source]
to update do CDN_IMG.PLACEHOLDER_SERVICE = “placebear.com/g” usage : img(_src=CDN_IMG.PLACEHOLDER(300,100)) default HTTP is none, to let the browser decide # use optional seperator if the site uses x instead of slash img(_src=CDN_IMG.PLACEHOLDER(300,100,’x’))
- class domonic.CDN.CDN_JS[source]
js libs
- AFRAME_1_2: str = 'https://aframe.io/releases/1.2.0/aframe.min.js'
- BOOTSTRAP_4: str = 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'
- BOOTSTRAP_5 = 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js'
latest
- BOOTSTRAP_5_ALPHA: str = 'https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js'
- BRYTHON_3_9_5: str = 'https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.5/brython.min.js'
- D3: str = 'https://cdnjs.cloudflare.com/ajax/libs/d3/7.4.3/d3.min.js'
latest
- D3_6_1_0: str = 'https://cdnjs.cloudflare.com/ajax/libs/d3/6.1.0/d3.min.js'
- HTMX: str = 'https://unpkg.com/htmx.org@1.7.0'
latest
- JQUERY: str = 'https://code.jquery.com/jquery-3.6.0.min.js'
latest
- JQUERY_3_5_1: str = 'https://code.jquery.com/jquery-3.5.1.min.js'
- JQUERY_UI: str = 'https://code.jquery.com/ui/1.12.0/jquery-ui.min.js'
- MATHML: str = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=MML_HTMLorMML'
- MODERNIZER_2_8_3: str = 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js'
- MOMENT_2_27_0: str = 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js'
- PIXI_5_3_3: str = 'https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.3.3/pixi.min.js'
- POPPER_1_16_1: str = 'https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js'
- SOCKET_1_4_5: str = 'https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js'
- UNDERSCORE: str = 'https://cdn.jsdelivr.net/npm/underscore@1.11.0/underscore-min.js'
- X3DOM: str = 'https://www.x3dom.org/download/x3dom.js'
domonic.utils¶
snippets etc
- class domonic.utils.Utils[source]
-
- static chunks(iterable, size: int, format=<built-in function iter>)[source]
Iterate over any iterable (list, set, file, stream, strings, whatever), of ANY size
- static dictify(arr: list) dict [source]
[turns a list into a dictionary where the list items are the keys]
- static digits(text: str = '') str [source]
[takes a string of mix of digits and letters and returns a string of digits]
- static frequency(data)[source]
[check the frequency of elements in the data]
- static has_internet(url: str = 'http://www.google.com/', timeout: int = 5) bool [source]
[check if you have internet connection]
- Parameters
url (str, optional) – [the url to check]. Defaults to ‘http://www.google.com/’.
timeout (int, optional) – [the timeout]. Defaults to 5.
- Returns
[True if you have internet]
- Return type
[bool]
- static init_assets(dir: str = 'assets') None [source]
[creates an assets directory with nested js/css/img dirs]
- Parameters
dir (str, optional) – [default directory name]. Defaults to ‘assets’.
- static is_linux() bool [source]
[check if the system is a linux]
- Returns
[description]
- Return type
[bool]
- static is_mac() bool [source]
[check if the system is a mac]
- Returns
[True if the system is a mac]
- Return type
[bool]
- static is_nix() bool [source]
[check if the system is a nix based system]
- Returns
[True if it is a nix based system]
- Return type
[bool]
- static is_windows() bool [source]
[check if the system is a windows]
- Returns
[True if windows]
- Return type
[bool]
- static permutations(word: str) list [source]
[provides all the possible permutations of a given word]
- static replace_between(content: str, match: str, replacement: str, start: int = 0, end: int = 0)[source]
[replace some text but only between certain indexes]
- Parameters
- Returns
[the new string]
- Return type
[str]
- static to_dictionary(keys: list, values: list) dict [source]
[take a list of keys and values and returns a dict]
- static truncate(text: str = '', length: int = 0) str [source]
[truncates a string and appends 3 dots]
domonic.decorators¶
- domonic.decorators.as_json(func)[source]
decorate any function to return json instead of a python obj note - used by JSON.py
- domonic.decorators.called(before=None, error: Optional[Callable[[Exception], None]] = None)[source]
Decorator to call a function before and after a function call.
- domonic.decorators.check(f)[source]
Prints entry and exit of a function to the console
- domonic.decorators.deprecated(func)[source]
marks a function as deprecated.
- domonic.decorators.el(element='div', string: bool = False)[source]
[wraps the results of a function in an element]
- domonic.decorators.iife(before=None, error: Optional[Callable[[Exception], None]] = None)
Decorator to call a function before and after a function call.
- domonic.decorators.instead(f, somethingelse)[source]
what to return if it fails
- domonic.decorators.log(logger, level='info')[source]
@log(logging.getLogger(‘main’), level=’warning’)
- domonic.decorators.silence(*args, **kwargs)[source]
stop a function from doing anything