Using Python bleach library with Google AppEngine - google-app-engine

I am looking to sanitize (remove all javascript for example) tinymce generated html code. This code will be rendered within a div on a page and the attempt is to remove all malicious code at the time of saving the tinymce generated code.
The Python bleach library seems to be the recommended route to take. Bleach is not present in the Google Appengine supported thirdparty libraries.
Does it mean that I have to install it along with my Python code to Google App Engine ?
Any suggestion for a better implementation is also welcomed.
Many Thanks.

Yes, any third party library not provided by the SDK, needs to be installed in your own project and deployed with your code.
See SDK Pure Python section of the docs https://developers.google.com/appengine/docs/python/#Python_Pure_Python
SO you will need to install html5lib-python as well as bleach directly in your project.

Related

How to use Adobe's React Web Component tool in AEM Maven project

I'm unable to figure out how to use #adobe/react-webcomponent in an AEM Maven multi-module project.
I have tried a similar tool which has a sample project, and it works, but I would much rather use Adobe's instead.
Currently I can not find much documentation on this tool other than the github page and cannot find any sample project at all that demonstrates how it is used.
An ideal resolution would be a working sample AEM Maven multi-module project that shows how to properly use #adobe/react-webcomponent to have React components available in AEM site editor. Thanks in advance for any help!
I don't have exactly what you're looking for, but I did some work with that in this branch of another Adobe project. It's about using a web-component to render a search box and a search results component written in React.

Loading TinyMCE without Cloud in React

I am working on React project that uses TinyMCE as a rich-text editor. I wanted to opt out of their cloud services so as to remove the following message.
This domain is not registered with TinyMCE Cloud. Start a free trial to discover our premium cloud services and pro support.
I tried out this link (Loading TinyMCE by yourself) from the TinyMCE website by adding the following code to my index.html file hoping that it would be accessible globally.
<script src="https://cloud.tinymce.com/5/tinymce.min.js"></script>
This did not work nevertheless. Am I missing something here?
The URL in your script tag is using our Cloud service to try to load the editor so if you don't want to use our Cloud platform, then that URL seems not to be what you want.
If you want to locally host TinyMCE in a React app. You can do so via a module loader as outlined here:
https://www.tiny.cloud/docs/advanced/usage-with-module-loaders/
If you want to use the script tag referenced in your question you need to register on our Cloud platform (it's free) to get an API key. Once you have that, you need to include that API key in your script tag as outlined here:
https://www.tiny.cloud/docs/cloud-deployment-guide/editor-and-features/
...so the script tag would look like this:
<script src="https://cloud.tinymce.com/5/tinymce.min.js?apiKey=your_API_key"></script>
...but with the string your_API_key replaced with your actual API key.
I'v got a new way to get rid of the cloud when using official tinymce react package.
Go to https://github.com/tinymce/tinymce-react, and clone the whole project.
Open the file src/main/ts/components/Editor.tsx, and go to line 122, where you can find the function named 'getScriptSrc'.
Remove all codes inside the function, and just return the url of your self hosted tinymce.min.js. In this way you can get official tinymce react but won't get bothered by the message.
Import Editor in src/main/ts/index.ts.

Integrating Angular CLI with Squarespace

I am interested to know if anyone has been able to successfully use Angular CLI in a Squarespace site.
I have been searching for answers to this problem but can't find a solution. I know that you can add custom scripts to a Squarespace site and/or add scripts via CDN but Angular CLI apps are usually deployed using a different method.
Any help is appreciated. Thanks!
NOTE: I know that this is not a best practice and devs should deploy their Angular CLI app via AWS or with a similar platform.
I'm surprised no one has answered this. Yes, there's no reason why you couldn't use AngularJS or any other Javascript library with Squarespace. You'll need a 'Business' level account, however, and you'll want to check out the developer portal here:
https://developers.squarespace.com
Squarespace provides you with a Git repository and a CLI that you can download via NPM that will let you run a local squarespace server and develop your site from scratch or with a base template.
You can check out their docs on 3rd party avascript (e.g. Angular) here:
https://developers.squarespace.com/custom-javascript/
Since your question is specifically about using the CLI, I would just note whatever your final 'production' bundle looks like and include that in your git repository, so that you can reference it in your main html page.

Pluggable-app-style for angularjs website

We are building a website allowing 3rd party (ourselves included) to write plugins and install into the platform. Basically, you can imagine of wordpress written in angularjs, and webmasters have options of install modules (for example Q&A , forum/whatever) into it.
I am thinking about something like this. Using server code to create main-app code (app.js as in standard naming)
angular.module("thePlatform", [
'plugin.forum',
'plugin.musicStore',
'plugin.whatever'
]);
whereas forum/musicStore/whatever are plugin that can be installed/unsinstalled into the platform.
Is that a good choice ? Or should we go for the SinglePage-Solution like that? If you have better approach, please !
Note: I did google before asking but couldn't find any answer:
https://softwareengineering.stackexchange.com/questions/239056/angularjs-structuring-a-web-application-with-multiple-ng-apps
AngularJS websites: single SPA vs multiple SPA apps/components

what is appengine_config.py

I am a noob trying to build an app on GAE. My app uses django templating features beyond those supported in version 0.96. I've not been able to get app engine (other than on the development server) to use the built in django 1.2 libraries.
I believe that this post might solve my problems except I don't know what appengine_config.py is. I assume I should include it in my project, but where and how? What should be in it other than the snippet in the post I referenced above?
Thanks!
appengine_config.py at the top level of your project is automatically imported by google.appengine.ext.webapp.util.run_wsgi_app() to add middlewear to webapp applications. The snippet you linked to should be sufficient to load django 1.2.
Simply paste it into appengine_config.py, and in your main.py (or wherever):
application = webapp.WSGIApplication([your_mappings])
run_wsgi_app(application)
Note that if you're not loading middlewear like appstats in appengine_config.py, you can actually just put the use_library() call directly into main.py; the key is to make sure it's always loaded before django is loaded from elsewhere on a given instance.

Resources