Load module in another custom module joomla - joomla

I have a module with simple pop-up that asks for authorization.
Also I have a authorization module called slogin that was included via <jdoc:include .. in the header of the website in the template.
So in my module that requires slogin system, I'm unable to do it via jdoc.
I tried also to import this module
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_slogin');
$attribs['style'] = 'xhtml';
echo JModuleHelper::renderModule($module, $attribs);
But I only got an ajax-loader. Any suggestions?

Related

Build fails with resolve errors

I am trying to setup socket.io-client inside a svelte component.
The docs say that I can do import { io } from 'socket.io-client'.
But when I try to run the app using the serve target, the command fails with the following logs:
Bundle complete. Watching for file changes...
Bundling...
'bufferutil' is imported by bufferutil?commonjs-external, but could not be resolved – treating it as an external dependency
'utf-8-validate' is imported by utf-8-validate?commonjs-external, but could not be resolved – treating it as an external dependency
Circular dependency: node_modules\util\util.js -> node_modules\util\node_modules\inherits\inherits.js -> node_modules\util\util.js
Circular dependency: node_modules\util\util.js -> node_modules\util\node_modules\inherits\inherits.js -> C:\Users\munda\Documents\upwork\upwork-gameshow\node_modules\util\util.js?commonjs-proxy -> node_modules\util\util.js
#rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
No name was provided for external module 'tty' in output.globals – guessing 'tty'
No name was provided for external module 'os' in output.globals – guessing 'os'
No name was provided for external module 'fs' in output.globals – guessing 'fs'
No name was provided for external module 'child_process' in output.globals – guessing 'require$$0'
No name was provided for external module 'http' in output.globals – guessing 'require$$1'
No name was provided for external module 'https' in output.globals – guessing 'require$$2'
No name was provided for external module 'net' in output.globals – guessing 'net'
No name was provided for external module 'tls' in output.globals – guessing 'tls'
No name was provided for external module 'crypto' in output.globals – guessing 'require$$0$3'
No name was provided for external module 'zlib' in output.globals – guessing 'zlib'
No name was provided for external module 'bufferutil' in output.globals – guessing 'require$$1$1'
No name was provided for external module 'stream' in output.globals – guessing 'require$$0$2'
No name was provided for external module 'utf-8-validate' in output.globals – guessing 'require$$0$1'
Creating a browser bundle that depends on Node.js built-in modules ("tty", "os", "http", "https", "zlib" and "stream"). You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node
Steps I took to generate the app:
Initiate an nx-workspace using yarn create nx-workspace
Install the svelte generators using yarn add #nxext/svelte, link: https://nx.dev/community#:~:text=the%20Nx%20workflow-,%40nxext/svelte,-Nx%20plugin%20to
Generate a svelte application using the installed generator.
Add the socket.io client side code in the component (basic socket initialisation as mentioned in docs).
Since my server and client are not going to be hosted on the same domain, add the import { io } from 'socket.io-client' and initialize the socket using const socket = io(SERVER_URL)(in my case this was http://localhost:3000)
Install socket.io client using yarn socket.io-client.
Run the serve target using nx run-many --target=serve --all --parallel, fingers crossed.
Result: The above mentioned log.
What am I missing?
I needed to install the following missing dependencies:
bufferutil
utf-8-validate
A simple yarn add bufferutil utf-8-validate fixed it for me. This is mentioned in docs for socket.io-client package or socket.io official documentation website.
This did fix builds on my PC (windows) but I could not get the same thing running on mac. I tried deleting node_modules and yarn.lock, re-running yarn.
Finally I had to go through the CDN route.
This is how I did it:
Move the socket initialisation logic in a function.
<script>
...
const initialiseSocket = () => {
socket = io('http://localhost:3000');
socket.on('messages', (data) => {
//...
});
}
</script>
Add a svelte:head tag to load the socket-io.client from CDN and pass the function to this script's on:load.
<svelte:head>
<script
src="https://cdn.socket.io/4.2.0/socket.io.min.js"
integrity="sha384-PiBR5S00EtOj2Lto9Uu81cmoyZqR57XcOna1oAuVuIEjzj0wpqDVfD0JA9eXlRsj"
crossorigin="anonymous"
on:load={initialiseSocket}></script>
</svelte:head>

How to Create a "File Template", for java code, in a new NetBeans Module?

I've taken the well-known Netbeans tutorial "NetBeans File Template Module Tutorial" which shows how to create an HTML template, shareable via a module. It worked fine, but when I attempted to create a Java template using a java file instead of an html file for a template, I get unrecognized character errors. There must be a way to create a java source code template? Note: this is not a "Code Template" or a "Code Generator", which are similar features in NetBeans, but not the same.
Example template code, copied from the NetBeans default Java template:
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* #author ${user}
*/
public class ${name} {
}
I've found the solution to my own question.
It's found in the JavaDoc for org.netbeans.api.templates Annotation Type TemplateRegistration.
In your module's "package-info.java", the #TemplateRegistration annotation has an argument of content. Add ".template" to the end of the template file name (i.e. "CustomJava.java", becomes "CustomJava.java.template").
Also, name your template file the same way. This prevents the IDE from interpreting the FreeMarker template file as a Java file.
Other than that, all is the same as in the previously mentioned tutorial "NetBeans File Template Module Tutorial"
Example using "CustomJava" as the template name:
#TemplateRegistration (
folder = "Other",
iconBase = "customjava/icon.png",
displayName = "#CustomJava_displayName",
content = "CustomJava.java.template",
description = "Description.html",
scriptEngine = "freemarker")

Where to put python module in spring boot application using Jython2.7?

I am using the Spring boot for an Java application and I want to put a python module my_module.py in the the app. I am trying to import the module like
interpretor.exec("import my_impodule")
But I am getting the error ImportError: No Module named my_module and when I check the current working directory using
interpretor.exec("import os\nprint os.getcwd()")
which gave me the path /my_project/ and my module location is /my_project/my_module.py which is correct. It should pick up the module if current working directory is this.
Can someone please help me where to put the python module so that I can picked up by Jython.
You need to set the Python module path. So that it can pick your module like this:
Properties pyProperties = new Properties();
pyProperties.put("python.path", System.getProperty("user.dir") + MODULE_PATH);
PythonInterpreter.initialize(System.getProperties(), pyProperties(), new String[0]);
PythonInterpreter pyInterpreter = new PythonInterpreter();

Why is Django missing the custom context processor?

My django 1.6 project is structured:
cg1
cg1
settings.py
cont_proc.py
inti, etc.
app
app
manage.py
templates
cont_proc.py reads:
from django.conf import settings
def misc(request):
return {'SITE_URL': settings.SITE_URL,'BALANCED_API_KEY':settings.BALANCED_API_KEY}`
in settings.py I have:
import django.conf.global_settings as DEFAULT_SETTINGS
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + ( os.path.join(BASE_DIR, 'cg1.cont_proc.misc'),)
BALANCED_API_KEY = os.environ.get('BALANCED_API_KEY')
SITE_URL = 'www.mysite.com' #but set up
python manage.py shell:
>>> from django.conf import settings
>>> settings.TEMPLATE_CONTEXT_PROCESSORS
['django_balanced.context_processors.balanced_library','django_balanced.context_processors.balanced_settings', 'django.contrib.auth.context_processors.auth']
>>>>import os
>>>>os.environ.get('BALANCED_API_KEY')
'correct key from a local .env file'
I've tried quite a few so question, especially: Where is template context processor in Django 1.5?
also: Python/Django is importing the wrong module (relative when it should be absolute)
but django doesn't seem to see my custom context processor, cont_proc, in the shell. And when I use render in views my templates do not receive the variables.
I had installed django-balanced. Apparently this was a mistake. I removed from installed apps and all was good.

How to export Plone session configuration?

I'd like to export my Plone session configuration to my portal product.
The session configuration is set via the ZMI -> acl-users -> session -> properties
I have tried creating a snapshot of the site but can't locate the session configuration within the snapshot xml...
Indeed, there is no GenericSetup configuration support included in plone.session; there is currently nothing that'll export it for you, nor anything to then import the settings.
You'd have to write a setup step for it instead, and configure the session plugin manually through that.
Add an import step to your configure.zcml configuration file:
<?xml version="1.0"?>
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
<genericsetup:importStep
name="yourpackage.a_unique_id_for_your_step"
title="Configures the plone.session plugin"
description="Perhaps an optional description"
handler="your.package.setuphandlers.setupPloneSession"
/>
</configure>
and add an empty 'sentinel' text file to the same profile directory named youpackage.setup-plonesession.txt
then add a setuphandlers.py module to your package (what handler points to in the above example):
def setupPloneSession(context):
if context.readDataFile('youpackage.setup-plonesession.txt') is None:
return
portal = context.getSite()
plugin = portal.acl_users.session
# Configure the plugin manually
plugin.path = '/'
plugin.cookie_name = '__ac'
plugin.cookie_domain = ''
# Set up a shared auth_tkt secret
plugin._shared_secret = 'YourSharedSecretKey'
plugin.mod_auth_tkt = True
Note that we first test if the sentinel file is present; if you reuse your package setup elsewhere the setup step could be run multiple times if you don't do this.
You'll need to refer to the plugin source to get an idea of what you can configure, I'm afraid.

Resources