django-cms editors and HTML data attribute cleaned up - django

Using django-cms 2.4 I need to create pages that contain bootstrap code, but the html5lib used cleans data-* attributes. No matter if you specify valid_element in TINYMCE_DEFAULT_CONFIG. (I still looking for a similar option for Wymeditor), because this is done in #plugins/text/models (clean_html function: https://github.com/divio/django-cms/issues/1529 )
Github issue:
https://github.com/divio/django-cms/issues/1529
What could it be a possible workaround?
How can I extend the text plugin in the admin part?
Thanks!

i belive the removing of the fields is done by html5lib that the cms uses as python package, you'll need to open html5lib folder and open sanitizer.py, in line 184 where the code is:
if name in self.allowed_attributes])
change to:
if name in self.allowed_attributes or re.match( r'data-.*',name)])
this will allow all data-(whatever) attributes
for WYMeditor the data-(whatever) attribute is already allowed

Related

How to highlight code in hbs template?

I want to introduce into my project some code to be highlighted on certain pages (like index.hbs) I've searched for libraries that can do this and found tools like highlight.js, but I was unable to use it in my ember project. Can anyone explain how to import a custom library like highlight.js or can someone give me a recomandation for a tool. I've tried to use this tool: ember-cli-eg-code-highlight, but it is not specified how to use it. Ok I have installed it, pasted the {{highlight-js code=file lang=language hasLineNumbers=hasLineNumbers}} in my index.hbs, but it does not work. Also the ENV.emberHighlightJs: { style: 'arta' };I have no ideea where to put it. Tried to put it inember-cli-build.js but it is not working.
I have found also markdown-code-highlighting. But I am lost at this step: "In your Brocfile you'll need to import the CSS styling you want for the highlighter. " So where exactly is my brocfile in my ember project?
Did you restart ember server ?
You can find example of using ember-cli-eg-code-highlight here: https://github.com/EmberGrep/ember-cli-eg-code-highlight/blob/master/tests/dummy/app/templates/application.hbs
But it looks like addon is buggy. So it worth to check this PR https://github.com/EmberGrep/ember-cli-eg-code-highlight/pull/9
P.S. about brocfile -- now it names as ember-cli-build.js at the root of project

Python installation doesn't support type of template loading

I've installed Aldryn-boilerplates, using Configuration block's advices from github (https://github.com/aldryn/aldryn-boilerplates#configuration).
But when I make python manage.py runserver I recieve a message:
/home/stp/env/local/lib/python2.7/site-packages/django/template/loader.py:110: UserWarning: Your TEMPLATE_LOADERS setting includes'aldryn_boilerplates.template_loaders.AppDirectoriesLoader', but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS.
warnings.warn("Your TEMPLATE_LOADERS setting includes %r, but your Python installation doesn't support that type of template loading. Consider removing that line from TEMPLATE_LOADERS." % loader)
The web page loads normally (without any template or style).
Also a question, where to put line ALDRYN_BOILERPLATE_NAME = 'bootstrap3'? I've placed it in the bottom of my project's settings.py file.
Anyone knows how to fix that? Or maybe there are another framework with much more detailed description about installation and configuration, which fits for beginners?
I got the some error with django 1.8 and a custom template loader. I had overridden the Loader class out of django.templates.loaders.base. To get rid of this error I also had to the set the class variable is_usable to true
class Myloader(Loader):
is_usable = True
So maybe you can solve your issue with subclassing the 'aldryn_boilerplates.template_loaders.AppDirectoriesLoader' and only change the class variable as shown above.
You have placed the ALDRYN_BOILERPLATE_NAME = 'bootstrap3' at the right place. Please mention the versions of python and django-cms you are using. If you want to try another blogging platform for python, then http://mezzanine.jupo.org/ is helpful for beginners, because it's very easy to setup.

How do I get tinymce edit windows to look like the site pages in django mezzanine?

Mezzanine is looking good and working well but I'm having trouble when I edit some blog posts and pages because the tinymce edit window displays in its own style using a very small font. I need it to be at least roughly WYSIWYG.
Following the documentation for django_tinymce and for tiny mce, I set up my settings thus:
TINYMCE_DEFAULT_CONFIG = {'theme': "simple",
'relative_urls': False,
'content_css': ','.join([os.path.join(STATIC_URL, path) for path in [
"css/animate.css",
"css/bootstrap.min.css",
"css/font-awesome.min.css",
"css/jquery.bxslider.css",
"css/main.css",
"css/mezzanine.css",
"css/bootstrap-theme.css",
"css/custom-styles.css"]]),
'theme_advanced_font_sizes': "10px,12px,13px,14px,16px,18px,20px",
'font_size_style_values': "10px,12px,13px,14px,16px,18px,20px"}
This has no effect. I'm not sure how to dig in and see what is going on. The above css files are all available when I type in the generated urls.
Mezzanine and django_tinymce have nothing to do with each other - presumably you're configuring software that isn't even installed.
From the Mezzanine docs:
If you’d only like to customize the TinyMCE options specified in its JavaScript setup, you can do so via the TINYMCE_SETUP_JS setting which lets you specify the URL to your own TinyMCE setup JavaScript file.
http://mezzanine.jupo.org/docs/admin-customization.html#wysiwyg-editor
Not quite as straight-forward as django-tinymce, but you can get to the same result.
Also note that the styles (such as the tiny font mentioned) have since been updated in the development version of Mezzanine, so if you build against that you might not even need to configure things:
https://github.com/stephenmcd/mezzanine/commit/6dff64bf058ac0e83c3c313b4167f8bbd1ac9560

templating system with zf2?

we are planing to create a CMS with zf2 and doctrine orm .
actually we are concern about our cms templating
we want our system works with several templates and easily change between themes via admin
and creating a new templates should be easy for end-users developers
we want an advice or suggest for how to build templating system that :
there is a core module and there a lot sub modules with their own phtml
so where to store theme1 phtml and where to store theme2 phtmls ...
any suggest or advice please
thanks
I encourage you to take a look at Twig, its the best template engine I have seen so far :) It does take some time to learn Twig syntax, but its well worthy if you look at what you get :)
I cant yet write comments, so I wrote this as an answare.
Hope this helps. Trust me, the Twig is the way to go. Joust look at his documentation for more specific details how to use it!
EDIT:
The problem you are trying to solve has nothing to do with template engine. You can do that with any template engine. You can do it even with plain PHP if you want.
I built web application where users can register, get their own sub domain, and there they can build their webpage. Change theme, edit text, add pages. Simple CMS functionality.
The easiest way to do this is to have themes folder, where you would store themes, like this:
themes/
- themeBlue
- css/
- images/
- js/
- html or views/
- themeRose
...
Now this is where you would place all your themes, every theme has its own folder with images, css, js files...
And then you would have users, and every user would be able to choose and change theme.
That information would be stored in database. You need to store that user Jack is using themeBlue. You can do that as you want. You can event put this in users table like user_theme column.
Now when someone visits site, you first query database to see what theme is that user or creator of web using. And then you load all that files from current theme folder. And populate html files with data stored in database like in any other CMS.
This is the simplest implementation. You could for example, store css and html files in database :)
Hope this answers your question.
Good luck with that, I almost gone mad building my system :) I ended up with writing my own PHP MVC Framework joust to accomplish what I wanted.
if you activate another module in the application.config.php which has the same views and layouts (same folder structure and filenames) it's viewscripts and layouts will automatically be used when it's loaded after your core module.
so you could simply make your application.config.php dynamic to load the active template module which only contains the view folder. this would be a simple and effective solution without any other libraries.
additionally you can use an asset manager like assetic to also provide images, css etc. inside of your (template-)modules. (have a look at zf2-assetic-module, I wrote my own assetize-module based on assetic to fit my needs...)
Sina,
I do this in my Application->Module.php onBootstrap
$ss = $serviceManager->get('application_settings_service');
$settings = $ss->loadSettings();
$serviceManager->get('translator');
$templatePathResolver = $serviceManager->get('Zend\View\Resolver\TemplatePathStack');
$templatePathResolver->setPaths(array(__DIR__ . '/view/'.$settings['theme'])); // here is your skin name
$viewModel = $application->getMvcEvent()->getViewModel();
$viewModel->themeurl = 'theme/'.$settings['theme'].'/';
In this situation I have this structure in my view folder
view/
default/
application/
error/
layout/
zfcuser/
red/
application/
error/
layout/
zfcuser/
The $viewmodel above injects a variable into the layout for the themeurl in the public_html folder /theme/red/ with all assets for red
Access in layout.phtml -> themeurl;?> in a viewscript layout()->themeurl;?>
I am still working out my Dynamic Views. Right now I have a BaseController and all my ActionControllers extend it. It has a render() function that builds the required views but not sure its going to be scalable hoping to try some placeholder ideas.
application_settings_service is a Settings Service that gets settings for whatever domain was used to call the system and builds an array accessible via any service aware part of the site. Thats a whole different post and it may or may not rub MVC peeps the wrong way
I know your question is marked answered just thought I would share
Eric

In my Django application i want to print one reciept, for that i am fallowing xhtml2pdf

In my Django application i want to print one reciept, for that i am fallowing html to pdf convert then in pdf automatically print options is there.
for that i am install python-pisa module and i has fallowing code but my common css is not apply how is it work..
Not all CSS styles are supported by pisa, check out
http://xhtml2pdf.appspot.com/static/pisa-en.html
There are also custom layout definitions for pisa (same link), so if you want to generate it straight from django you should define a different template for this purpose.