frontend package

Submodules

frontend.family module

Created on 2021-01-01

@author: wf

class frontend.family.LocalWiki(siteName: str, family=None, localSettings: Optional[str] = None)[source]

Bases: object

a local Wiki

get the local path to the logo file of this wiki

Returns

the logo path if logo is defined as file else None

Return type

str

getSetting(varName: str) str[source]

get the setting of the given variableName from the LocalSettings.php

Parameters

varName (str) – the name of the variable to return

Returns

the value of the variable

Return type

str

getStatusCode(timeout=0.5)[source]

get the status Code for my url

Parameters

timeout (float) – the maximum time to wait for a response

Returns

html statusCode or -1 if there was a timeout

Return type

int

class frontend.family.WikiBackup(wikiuser)[source]

Bases: object

find out details about a WikiBackup

potentially this class needs to move upstream to py-3rdparty-MediaWiki

exists() bool[source]

check if this Backup exists

Returns

True if the self.backupPath directory exists

Return type

bool

hasGit() bool[source]

check if this Backup has a local git repository

Returns

True if the self.gitPath directory exists

Return type

bool

class frontend.family.WikiFamily(sitedir: str = '/var/www/mediawiki/sites')[source]

Bases: object

the wiki family found in the given site dir

frontend.server module

Created on 2021-01-06

@author: wf

class frontend.server.Server(debug=False)[source]

Bases: JSONAble

a server that might serve multiple wikis for a wikiFarm

checkApacheConfiguration(conf, status='enabled') str[source]

check the given apache configuration and return an indicator symbol

Parameters

conf (str) – the name of the apache configuration

Returns

a state symbol

enableFrontend(siteName: str, appWrap=None, debug: bool = False)[source]

enable the given frontend

Parameters
  • siteName (str) – the siteName of the frontend to enable

  • appWrap (appWrap) – optional fb4 Application Wrapper

Returns

the configured frontend

Return type

Frontend

getFrontend(wikiId)[source]

get the frontend for the given wikiid

Parameters

wikiId (str) – the wikiId to get the frontend for

Returns

the frontend for this wikiId

Return type

Frontend

get the logo url for the platform this server runs on

Returns

the url of the logo for the current operating system platform

Return type

str

getStorePath(prefix: str = 'serverConfig') str[source]

get the path where my store files are located :returns: path to .wikicms in the homedirectory of the current user

homePath = None
load()[source]

load my front end configurations

reinit(debug=False)[source]

reinitialize me

render()[source]

render me

sqlBackupState(dbName)[source]

get the backup state of the given sql backup

Parameters

dbName (str) – the name of the database to check

Returns

backup State

Return type

dict

sqlBackupStateAsHtml(dbName)[source]

get the backup state of the given sql backup

Parameters

dbName (str) – the name of the database to check

Returns

backup State html representation

Return type

html

sqlDatabaseExist(dburl: str) bool[source]

check if the database with the given name exists

Parameters

dburl (str) – rfd 1738 formatted database url e.g. mysql://dt_admin:dt2016@localhost:3308/dreamteam_db

Returns

True if the database exists, else False

sqlGetDatabaseUrl(dbname: str, username: str, password: str, hostname: Optional[str] = None) str[source]

get the DatabaseUrl for the given database Name

Parameters
  • dbname (str) – the name of the database

  • username (str) – the username

  • password (str) – the password

Returns

the url for sqlAlchemy in rfc1738 format e.g. mysql://dt_admin:dt2016@localhost:3308/dreamteam_db

Return type

str

stateSymbol(b: bool) str[source]

return the symbol for the given boolean state b

Parameters

b (bool) – the state to return a symbol for

Returns

✅ for True and ❌ for false

store()[source]

frontend.site module

Created on 2020-12-31

@author: wf

class frontend.site.Site(name: str, defaultPage: str = 'Main Page', lang: str = 'en', debug=False)[source]

Bases: object

migrated from: https://github.com/BITPlan/com.bitplan.wikifrontend/blob/master/src/main/java/com/bitplan/wikifrontend/Site.java

configure(config: dict)[source]

configure me from the given configuration :param config: the configuration to use :type config: dict

open(appWrap=None)[source]

open this site

Parameters

appWrap (appWrap) – optional fb4 Application Wrapper

frontend.webserver module

Created on 2020-12-30

@author: wf

class frontend.webserver.WikiCMSWeb(host='0.0.0.0', port=8251, debug=False)[source]

Bases: AppWrap

Wrapper for Flask Web Application

adminMenuList(activeItem: Optional[str] = None)[source]

get the list of menu items for the admin menu :param activeItem: the active menu item :type activeItem: str

Returns

the list of menu items

Return type

list

enableSites(siteNames)[source]

enable the sites given in the sites list :param siteNames: a list of strings with wikiIds to be enabled :type siteNames: list

family() str[source]

show a html representation of the family of wikis on this server (if any)

Returns

a html table of all wikis in the family

Return type

str

frontends() str[source]

render the frontends view

Returns

the html for the admin view

Return type

str

initDB()[source]

initialize the database

initUsers()[source]

render the Logo for the given siteName

Parameters

siteName (str) – the name of the site e.g. wiki.bitplan.com

Returns

the rendered Logo for the given Site

static splitPath(path)[source]

split the given path :param path: the path to split :type path: str

Returns

the site of the path an the actual path

Return type

str,str

wikis() str[source]

render the wikis table

Returns

the html code for the table of wikis

Return type

str

wrap(siteName, path)[source]

wrap the given path for the given site :param siteName: the name of the site to wrap :type siteName: str :param path: the path to wrap :type path: path

render the Logo for the given siteName

Parameters

siteName (str) – the name of the site e.g. wiki.bitplan.com

Returns

the rendered Logo for the given Site

frontend.webserver.wrap(path)[source]

wrap the url request for the given path

Parameters

path (str) – the path to wrap - the path should start with /<wikiId>/ followed by the actual path in the wiki

frontend.widgets module

frontend.wikicms module

Created on 2020-07-27

@author: wf

class frontend.wikicms.Frontend(siteName: str, debug: bool = False, filterKeys=None)[source]

Bases: object

Wiki Content Management System Frontend

checkPath(pagePath)[source]

check the given pathPath

Parameters

pagePath (str) – the page Path to check

Returns

None or an error message with the illegal chars being used

Return type

str

doFilter(html, filterKeys)[source]
errMsg(ex)[source]
filter(html)[source]
fixHtml(soup)[source]

fix the HTML in the given soup

Parameters

soup (BeautifulSoup) – the html parser

fixImages(soup)[source]
fixNode(node, attribute, prefix, delim=None)[source]

fix the given node

node(BeautifulSoup): the node attribute(str): the name of the attribute e.g. “href”, “src” prefix(str): the prefix to replace e.g. “/”, “/images”, “/thumbs” delim(str): if not None the delimiter for multiple values

getContent(pagePath: str)[source]

get the content for the given pagePath :param pagePath: the pagePath :type pagePath: str :param whatToFilter: list of filter keys :type whatToFilter: list

Returns

the HTML content for the given path

Return type

str

getFrame(pageTitle)[source]

get the frame template to be used for the given pageTitle#

Parameters

pageTitle (str) – the pageTitle to get the Property:Frame for

Returns

the frame or None

Return type

str

log(msg)[source]

log the given message if debugging is true

Parameters

msg (str) – the message to log

needsProxy(path: str) bool[source]
Parameters

path (str) – the path to check

Returns

True if this path needs to be proxied

open(appWrap=None)[source]

open the frontend

Parameters

appWrap (appWrap) – optional fb4 Application Wrapper

proxy(path: str) str[source]

proxy a request see https://stackoverflow.com/a/50231825/1497139

Parameters

path (str) – the path to proxy

Returns

the proxied result Request

render(path: str, **kwargs) str[source]

render the given path

Parameters
  • path (str) – the path to render the content for

  • kwargs() – optional keyword arguments

Returns

the rendered result

Return type

str

renderTemplate(template, **kwargs)[source]

render the given template with the given arguments

Parameters
  • template (str) – the template file to be used

  • kwargs() – same arguments a for dict constructor

Returns

the rendered result

Return type

str

toReveal(html)[source]

convert the given html to reveal

unwrap(soup)[source]
wikiPage(pagePath)[source]

get the wikiPage for the given pagePath

Parameters

pagePath (str) – the page path

Returns

the pageTitle

Return type

str

Module contents