I have newly added messageFormatter and messageBuilder similar to:
<messageFormatter contentType="application/hal+json" class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
<messageBuilder contentType="application/hal+json" class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
In this two files:
[API-HOME]/repository/conf/axis/axis2.xml
[API-HOME]/repository/conf/axis/axis2_blocking_client.xml
in API Manager version 3.0.0.
But in the APIM version 3.0.0 all changes in this files discards because any server configuration is: [API-HOME]/repository/conf/deployment.toml, reference: https://github.com/wso2/docs-apim/issues/498
What is the correct way of adding these lines ?
Thanks!
Try this.
1) Open repository/resources/conf/templates/repository/conf/axis2/axis2.xml.j2.
i) Add these under <messageFormatters>
{% for message_formatter in custom_message_formatters %}
<messageFormatter contentType="{{message_formatter.content_type}}"
class="{{message_formatter.class}}"/>
{% endfor %}
ii) Add these under <messageBuilders>
{% for message_builder in custom_message_builders %}
<messageBuilder contentType="{{message_builder.content_type}}"
class="{{message_builder.class}}"/>
{% endfor %}
2) Add this to deployment.toml
[[custom_message_builders]]
content_type = "application/hal+json"
class="org.apache.synapse.commons.json.JsonStreamBuilder"
[[custom_message_formatters]]
content_type = "application/hal+json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"
Ref: https://ei.docs.wso2.com/en/latest/micro-integrator/setup/message_builders_formatters/message-builders-and-formatters/#custom-message-formatter
In API Manager 3.0.0, adding custom message builders, formatters cannot be done with the deployment.toml file.
Therefore, if you need to configure additional message builders, formatters, you need to edit the <APIM_HOME>/repository/resources/conf/templates/repository/conf/axis2/axis2.xml.j2
and add the required message builder and formatter.
Related
I am new to docker. Starting from a Django project (Django 4.0), I am using Docker to side by side with Nginx.
I used a docker-compose.yml file and used a custom configuration of Nginx, and everything works.
Only when I go to the login screen and click the "Login" button it comes up "Forbidden (403) CSRF verification failed. Request aborted.".
The code inside login.html is like this
<form method="post">{% csrf_token %}
{{ form|crispy }}
<button class="btn btn-success ml-2" type="submit">Log In</button>
Thanks in advance!
I would recommend you to read through all of these settings starting with "CSRF_" here
As you did not provide your settings.py I can only guess that the problem lays in there. Your form template is fine.
Probably my link leads you already to the correct setting, called CSRF_TRUSTED_ORIGINS where you basically input all your domains that you want to trust as a list. (Trust meaning which domain is allowed to send a post request)
settings.py:
CSRF_TRUSTED_ORIGINS = [
'https://trusted.domain.one.com',
'https://trusted.domain.two.com'
]
If this does not work try also to add the 'http://trusted.domain.one.com' without the S in httpS.
I am using Facebook's share button on my Django app.
I'm using Facebook's SKD instructions which tell me to place this code wherever you want the plugin to appear on your page:
<div class="fb-share-button"
data-href="https://my-website-full-url"
data-layout="button" data-size="small" data-mobile-iframe="false">
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse">Share
</a>
</div>
So I placed that code in my template but how do I add the full URL of the web page with the FB share button in the data-href attribute?
As long as you have django.template.context_processors.request enabled you should be able to use request.build_absolute_uri() in your template:
data-href="{{ request.build_absolute_uri }}"
This should work out of the box if you're using a fairly recent version of Django.
I am experiencing this strange error only on my production environment. It works fine locally and on staging.
I'm using Django==1.10.5 & django-blog-zinnia==0.18.1 with zinnia-wysiwyg-ckeditor==1.3. I believe this issue happened recently when we upgraded from Django==1.8 to the latest.
When I try to create a blog entry, I can't edit the content because the ckeditor instance does not load. The errors are:
https://example.com/admin/zinnia/entry/81/change/config.js/change/ 404 (Not Found)
https://example.com/admin/zinnia/entry/81/change/lang/en.js/change/
GET https://example.com/admin/zinnia/entry/81/change/skins/moono-lisa/editor.css/change/
Uncaught TypeError: Cannot set property 'dir' of undefined
The URL is /admin/zinnia/entry/81/change/
So this very much looks like ckeditor.js is trying to load additional static files based on the current URLs and somehow it injects the filenames into the current URL.
As a workaround, I ssh-ed into the server and manipulated /static/ckeditor/ckeditor/ckeditor.8bd276b5ef4c.js and added this line at the very top:
window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';
This solves the issue. The big question is: Why does this only happen on one of my machines, why does Django/zinnia not set CKEDITOR_BASEPATH correctly by itself?
I'm posting this here because I am not sure if this is an issue in Django, zinnia or zinnia-ckeditor, if anyone got insights on who is guilty, I'm happy to re-post this issue on the relevant issue tracker on github.
EDIT:
As a workaround, in my project I created the file templates/admin/change_form.html:
{% extends "admin/change_form.html" %}
{% block extrahead %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>
{{ block.super }}
{% endblock %}
I have been able to build a simple CRUD app for a project using the Symfony EasyAdminBundle and it has worked great for the normal entity based use cases. I have some additional use cases though where I want to do things like rebuilding data. For these I have to capture certain request attributes, pass over to a controller and then delegate to a backend API call to a remote service.
This can all be done in Symfony but I am running into trouble with how to wire this into the EasyAdmin view/method of working. Ideally I want this to be a page inside easy admin and not lose the left menu etc. So far, the only way I have found to do this is to create a Model class what is using one of the existing tables but has only some properties I would need to drive into the API. I then override the controller actions so rather than do a default save, I handle against that remote API.
The problem with this approach is that obviously I am now bound to Doctrine entities and that would be problematic for requests that were not mappable to the database.
Is there a way to define a logical entity that would let me leverage associations so I can have lookups etc, that will wire into the bundle seamlessly, but are not actually tied to a backend database table or view?
I am adding my response for people who may still face this issue in the future.
How I solved this without creating an entity :
Create a custom controller: symfony console make:controller
Edit the controller's view to inherit the EasyAdmin layout :
{# ./src/templates/home/index.html.twig #}
{% extends '#EasyAdmin/Default/layout.html.twig' %}
{# Let\'s remove/empty the header #}
{% block content_header_wrapper %} {% endblock content_header_wrapper %}
{# The main page content block #}
{% block main %}
**PUT YOUR CODE HERE**
{% endblock main %}
{# Let\'s remove/empty the footer #}
{% block content_footer_wrapper %} {% endblock content_footer_wrapper %}
Add your page to the side navigation
design:
menu:
- {route: 'home', label: 'Home', default: true, icon: 'home'}
- {entity: 'MyEntity', label: 'My Relevant Entity', icon: 'briefcase'}
I'd solve this problem creating a custom action as explained here (probably you want a route-based action) and then use a template that extends from #EasyAdmin\default\layout.html.twig or any other default template similar to what you want to achieve.
Here is solution:
{# easy_admin/form.html.twig #}
{% block _product_custom_title_widget %}
{# ... #}
More information
{% endblock %}
Finally, add this custom theme to the list of themes used to render backend forms:
easy_admin:
# ...
design:
form_theme:
- 'horizontal'
# the following Twig template can be located anywhere in the application.
# it can also be added to the twig.form_themes option to use it in the
# entire application, not only the backend
- 'easy_admin/form.html.twig'
Here is link for more information: https://symfony.com/doc/master/bundles/EasyAdminBundle/book/edit-new-configuration.html
Easyadmin is a bundle and you can customize all the pages of any bundle.
This logic applies to any template that lives in a bundle: just follow the convention: app/Resources/{BUNDLE_NAME}/views/{PATH/TO/TEMPLATE.html.twig}.
Suppose you've installed an imaginary open-source AcmeBlogBundle in your project. And while you're really happy with everything, you want to override the template for a blog list page. Inside the bundle, the template you want to override lives at Resources/views/Blog/index.html.twig.
To override the bundle template, just copy the index.html.twig template from the bundle to app/Resources/AcmeBlogBundle/views/Blog/index.html.twig (the app/Resources/AcmeBlogBundle directory won't exist, so you'll need to create it). You're now free to customize the template.
Reference: https://symfony.com/doc/3.4/templating/overriding.html
I can successfully use django-allauth to let users login via facebook's OAuth2 mechanism. Now I'd like to enable login via facebook's JS sdk.
The docs say that
For Facebook both OAuth2 and the Facebook Connect Javascript SDK are supported. You can even mix the two.
Unfortunately, the example code doesn't show how to use the js sdk. By reading the code I found out that I need to set
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email', 'publish_stream'],
'METHOD': 'js_sdk' # instead of 'oauth2'
}
}
and include the following snippet in the body tag of my html template
{% include "facebook/fbconnect.html" %}
I have also added the following to my TEMPLATE_CONTEXT_PROCESSORS:
allauth.account.context_processors.account
allauth.socialaccount.context_processors.socialaccount
For some reason, this seems not to be enough, since none of the variables to be replaced in facebook/fbconnect.html seem to be set, resulting in them being replaced by empty strings. Also, the link produced by {% provider_login_url 'facebook' method='js_sdk' %} is just javascript:FB_login(''), which is obviously wrong.
What am I missing?
I just found out how to do it. Instead of doing
{% include "facebook/fbconnect.html" %}
I should do
{% providers_media_js %}