Package: fab-coreui-theme
FAB CoreUI ThemeCoreUI theme for FlaskAppbuilderThis theme is stillvery mucha WIP. If you’d like to use it take a look at thefab_coreui_theme/templates/coreui/init.htmland start overriding the blocks to make it your own.UsageThis theme is meant to be with used withFlaskAppbuilder. Just grab the coreui_bp from fab_coreui_theme and you’re ready to use the views. Here is an example app.QuickStartfromflask_appbuilder.models.sqla.interfaceimportSQLAInterfacefromfab_coreui_theme.fab_coreui_themeimportCoreUIBaseView,CoreUIModelView,CoreUISimpleFormView,coreui_bp# Make sure you import your app and register the blueprint!from.wwwimportappapp.register_blueprint(coreui_bp)# Create a base view that inherits from CoreUIBaseViewclassMyView(CoreUIBaseView):default_view='blank'@expose('/blank')@has_accessdefblank(self):returnself.render_template('coreui/init.html')# Register the view with AppBuilderappbuilder.add_view(MyView,"My View",category='My View')Bootstrap the Flask AppMake sure the FlaskAppbuilder is used. If you used the fab cli to initialize the project it should be in there somewhere.importloggingfromflaskimportFlaskfromflask_appbuilderimportAppBuilder,SQLAfromflask_appbuilder.menuimportMenulogging.basicConfig(format="%(asctime)s:%(levelname)s:%(name)s:%(message)s")logging.getLogger().setLevel(logging.DEBUG)app=Flask(__name__)app.config.from_object("config")db=SQLA(app)appbuilder=AppBuilder(app,db.session,menu=Menu(reverse=False),)from.importviews# noqaThis registers the CoreUIFlaskBlueprint. (This is only shown here for reference.)# This is only shown for reference.TEMPLATE_FOLDER=os.path.join(os.path.dirname(__file__),'templates')STATIC_FOLDER=os.path.join(os.path.dirname(__file__),'static')STATIC_URL_PATH='/static/coreui'# Use the Flask Blueprint to create an appized app and setup our routing# https://flask.palletsprojects.com/en/2.0.x/blueprints/#templatescoreui_bp=Blueprint('coreui_theme',__name__,template_folder=TEMPLATE_FOLDER,static_folder=STATIC_FOLDER,static_url_path=STATIC_URL_PATH)Then in  your HTML templates you can bring in the static files relative tostatic-{{url_for('coreui_theme.static',filename='coreui/node_modules/@coreui/coreui/dist/js/coreui.bundle.min.js')}}Example Base Viewfromflask_appbuilder.models.sqla.interfaceimportSQLAInterfacefromfab_coreui_theme.fab_coreui_themeimportCoreUIBaseView,CoreUIModelView,CoreUISimpleFormView,coreui_bp# Make sure you import your app and register the blueprint!from.wwwimportappapp.register_blueprint(coreui_bp)# Create a base view that inherits from CoreUIBaseViewclassMyView(CoreUIBaseView):default_view='blank'@expose('/blank')@has_accessdefblank(self):returnself.render_template('coreui/init.html')# Register the view with AppBuilderappbuilder.add_view(MyView,"My View",category='My View')Example Form Viewfromflask_appbuilder.fieldwidgetsimportBS3TextFieldWidgetfromflask_appbuilder.formsimportDynamicFormfromflask_babelimportlazy_gettextfromwtformsimportStringFieldfromwtforms.validatorsimportDataRequiredfromfab_coreui_theme.fab_coreui_themeimportCoreUIBaseView,CoreUIModelView,CoreUISimpleFormView,coreui_bp# Make sure you import your app and register the blueprint!from.wwwimportappapp.register_blueprint(coreui_bp)# Declare the FormclassTestForm(DynamicForm):TestFieldOne=StringField(lazy_gettext("Test Field One"),validators=[DataRequired()],widget=BS3TextFieldWidget(),)TestFieldTwo=StringField(lazy_gettext("Test Field One"),validators=[DataRequired()],widget=BS3TextFieldWidget(),)# Create the Form View and inherit from the CoreUISimpleFormViewclassTestFormView(CoreUISimpleFormView):form=TestFormform_title="This is my Test Form"default_view="this_form_get"message="My form submitted"defform_post(self,form):# process formflash(as_unicode(self.message),"info")# Register the viewappbuilder.add_view(TestFormView,"My form View",icon="fa-group",label="My Test form")Example Model Viewfromflask_appbuilder.models.sqla.interfaceimportSQLAInterfacefromfab_coreui_theme.fab_coreui_themeimportCoreUIBaseView,CoreUIModelView,CoreUISimpleFormView,coreui_bp# Make sure you import your app and register the blueprint!from.wwwimportappapp.register_blueprint(coreui_bp)classProductModelView(CoreUIModelView):datamodel=SQLAInterface(ProductModel)appbuilder.add_view(ProductModelView,"Products",icon="fa-group",label="Products")ExtendingIf you see something you don’t like you can customize it by overriding the blocks in the templates.Customization - Flask AppBuilder - Server SideSee theFlask AppBuilder docs on Customizationto customize the theme. You can fork this project, or create a new project that overrides blocks and templates.In your app create atemplates/mytheme/index.htmlfile.Override a block entirely -{% extends "coreui/init.html" %}

{% block content %}<h1>My content!</h1>{% endblock %}Extend a block -{% extends "coreui/init.html" %}

{% block content %}
        {{ super() }}<h1>My content!</h1>{% endblock %}See thefab_coreui_theme/templates/coreui/init.htmlfor the menus, breadcrumbs, and sidebars.Please note that menus are not implemented the way they are in FlaskAppbuilder and registering a view does not populate the menus.Further Customization - CoreUI - Front EndSome relevant docs:CoreUI DocsThemingBuild ToolsWeb PackCoreUI LayoutCoreUI IconsInstall the javascript node_modules.# Clone or fork the repo and clone it locallycdfab_coreui_theme/coreui_theme/staticnpminstall# or use the MakeFile - make npm-installIf this command gives you trouble try removing the package-lock.json and deleting the node_modules folder.Then you can reference the js and css files as:<scriptsrc="{{url_for('coreui_theme.static',filename='coreui/node_modules/thing.js')}}"></script><linkhref="{{url_for('coreui_theme.static',filename='coreui/node_modules/thing.css')}}"rel="stylesheet"/>LicensesFree software: MIT licenseDocumentation:https://fab-coreui-theme.readthedocs.io.FeaturesCoreUI Theme - Flask BlueprintCoreUI Theme - Flask AppBuilder BaseViewCoreUI Theme - Flask AppBuilder ModelViewCoreUI Theme - Flask AppBuilder SimpleFormViewCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template. It makes use of Flask AppBuilder and CoreUI.History0.1.0 (2021-08-28)First release on PyPI.