How To Deploy: Installing Mezzanine Theme - themes

How to install Mezzanine Theme exactly, step-by-step?
E.g., Moderna free theme.

Preconditions:
0) Versioning
Python 2.7.6.
Django 1.6.10
Mezzanine 3.1.10
Moderna v.? (static content)
1) I used PythonAnywhere for hosting
2) I followed this way to install Mezzanine: here, at the bottom there are links to PythonAnywhere specific guides
3) So, initial state is: Mezzanine is deployed, empty, with default theme.
4) [optional] Basic templates are collected (~80 of them it was)
5) Static is collected via python manage.py collectstatic
1. Add moderna to project
That's a simple step.
You should go to site with theme (for moderna it's here ) and download it. It will be a Django App, probably zipped into archive.
If app is zipped, unzip it.
Move it to your Mezzanine project folder (the one, which got created by command mezzanine-project myproject)
Folder structure should become:
myproject/
+-deploy/
+-static/
+-templates/ [in case you chose to collect them]
+-moderna/ [our new theme]
|
+-__init__.py
+-settings.py
+-urls.py
+-manage.py
+-wsgi.py
|
+-[some other things]
2. Change settings.py
open settings.py of your Mezzanine project
add moderna/templates to TEMPLATE_DIRS in settings.py 1st recor. The point is to give new directions to template loaders - now they 1st look for templates in moderna. Should now look like this:
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, "moderna/templates"),
os.path.join(PROJECT_ROOT, "templates"),
)
add moderna app to INSTALLED_APPS in settings.py above all (I presume, that's for Moderna's views, models etc. - backend for templates)
3. New Static Files
collectstatic again - now it will grab moderna's static
4. URLConf
in urls.py, use DIRECT_TO_TEMPLATE selected for / (root url), it should look like this:
urlpatterns += patterns('',
url("^$", direct_to_template, {"template": "index.html"}, name="home"),
("^", include("mezzanine.urls")),
...
5. Reload
I guess some servers would pick up new settings and urls automatically. Those which don't should be reloaded manually to catch up and start showing your beautiful new theme.
6. Customization begins
Now you can start customizing Moderna theme via base.html and index.html files in myproject/moderna/templates/ folder.
Postscriptum
I welcome any corrections and extensions, I'm not an expert in Mezzanine customization and the topic has many of slippery slopes.

Related

Problem configuring CKEDITOR in Magnolia RichTextField

I can't customize toolbar buttons in Magnolia's RichTextField
in Yaml file add configJsFile: /ckeditor/configJsFile.js pointing to config file under resource folder in java module project
- name: text
class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition
configJsFile: /ckeditor/configJsFile.js
i18n: true
once configJsFile.js added RichTextField start showing up all imaginable buttons and it is too many
I tried to remove some buttons groups in configJsFile.js even comment out all content inside config funtion CKEDITOR.editorConfig = function( config ) { ... } that's make any effect.
Any idea how I can configure toolbar content in Magnolia's RichTextField?
Here is original configJsFile.js taken from Magnolia doc site
Which version of Magnolia are you using?
Worst case scenario you can change the default settings from
'ckeditor/config-default.js'
Hope that helps,
Cheers,
I was wrong assuming that magnolia pointed to java resources.
Once I put CKEditor config file into folder from magnolia properties I've got what I wanted
see magnolia.resources.dir=${magnolia.home}/modules

Calls From External Web Components in PWAs [duplicate]

We are running 2 servers. Server 1 hosts a react application. Server 2 hosts a webcomponent exposed as a single javascript bundle along with some assets such as images. We are dynamically loading the webcomponent Javascript hosted on Server 2 in our react app hosted on Server 1. The fact that it is a webcomponent might or might not affect the issue.
What's happening is that the webcomponent makes uses of assets such as images that are located on Server 2. But when the react app loads the webcomponent, the images are not found as its looking for the images locally on Server 1.
We can fix this in many ways. I am looking for the simplest fix. Since Server 1 app and Server 2 apps are being developed by different teams both should be able to develop in the most natural way possible without making allowances for their app being potentially loaded by other apps.
The fixes that I could think of was:
Making use of absolute URLs to load assets - Need to know the deployed location in advance .
Adding a reverse proxy to Server 1 to redirect to Server 2 whenever a particular path is hit - Need to configure this. The React app could load hundreds of webcomponents, viz we need add a lot of reverse proxies.
Embed all assets into the single javascript on Server 2, like embed svgs into the javascript. - Too limiting. If the SVGs are huge and will make the bundle size bigger.
I was hoping to implement something like -
Since the react app knows where to hit Server 2, can't we write some clever javascript that will make the browser go to Server 2 whenever assets are requested by a Javascript loaded by Server 2.
If you download your Web Component via a classic script (<script> with default type="text/javascript") you can retrieve the URL of the loaded file by using document.currentScript.src.
If you download the file as a module script (<script> with type="module"), you can retrieve the URL by using import.meta.url.
Parse then the property to extract the base path to the Web Component.
Example of Web Component Javascript file:
( function ( path ) {
var base = path.slice( 0, path.lastIndexOf( '/' ) )
customElements.define( 'my-comp', class extends HTMLElement {
constructor() {
super()
this.attachShadow( { mode: 'open' } )
.innerHTML = `<img src="${base}/image.png">`
}
} )
} ) ( document.currentScript ? document.currentScript.src : import.meta.url )
How about uploading all required assets to a 3rd location, or maybe an AWS S3 bucket, Google Drive, Dropbox etc.? That way those assets always have a unique, known URL, and both teams can access them independently. As long as the names remain the same, so will the URLs.

WebPack in VS2015: How to configure a new pack?

I've started with a template from this extension to have a running angular2+ .net core starting point. I didn't want to use boostrap, but materialize-css, so I removed the bootstrap package in package.json, instead I added "materialize-css": "0.98.0",
Then I edited the webpack.config.vendor.js, I removed bootstrap and added materialize-css to the "vendor" list.
Then I rebuilt everything, but it seems that materialize-css is still not present(cannot find its css classes). I tried to clear the browser cache, tried even to open on a brand new browser(edge), but still, no materialize-css classes.
What did I miss?
EDIT
Currently, my vendor list is the following:
vendor: [
'#angular/common',
'#angular/compiler',
'#angular/core',
'#angular/http',
'#angular/platform-browser',
'#angular/platform-browser-dynamic',
'#angular/router',
'#angular/platform-server',
'angular2-universal',
'angular2-universal-polyfills',
'materialize-css',
'es6-shim',
'es6-promise',
'jquery',
'zone.js',
]
You're doing everything correctly, just need to do one thing slightly differently. In your webpack.config.vendor.js, instead of materialize-css, add materialize-css/dist/css/materialize.css to the vendor array:
...
entry: {
vendor: {
...
'materialize-css/dist/css/materialize.css',
...
}
}
This will include the css to your resulting bundle. If you also need fonts and js from materialize-css, you'll need to configure appropriate loaders, see https://www.npmjs.com/package/materialize-loader

Integrating extjs 5 app build with sencha cmd and WebAPI in Visual Studio

I'm new to ExtJs and want to integrate ExtJs 5 app created with Sencha CMD to WebAPI app!
I did the integration for BUILD mode, but not for the DEVELOPMENT mode.
Regarding to this post
the steps of integration are done as show below!
Step 1. Creating the path: C:\VCProject\SVCodeCampWeb\WebAPI
Step 2. Creating the WebAPI project named 'API_NAME' on the directory of Step 1.
Step 3. Moving ExtJS 5 framework (ext-5.0.0) to the directory of Step 1.
Step 4. Generating the extjs app with sencha cmd:
C:\VCProject\SVCodeCampWeb\WebAPI\ext-5.0.0>sencha generate app MyApp
C:\VCProject\SVCodeCampWeb\WebAPI\API_NAME\API_NAME\CMDBUG1
Step 5. Including the ext app to Web Api through the Solution Explorer.
Step 6. Building the app with sencha cmd as shown below:
C:\Users\albert\Documents\Visual Studio 2013\Projects\BMSIA\BMSIA.Web\BMSJS>sencha app build
WORKS!!!
These are the files that I included in my _Layout.chtml of the WebAPI for BUILD mode and works!
<script src="~/CMDBUG1/build/production/MyApp/app.js"></script>
<link href="~/CMDBUG1/build/production/MyApp/resources/MyApp-all.css" rel="stylesheet" />
ERROR SECTION!!!
And for DEVELOPMENT mode I'm including these files:
< link href="~/CMDBUG1/build/production/MyApp/resources/MyApp-all.css" rel="stylesheet" />
< script src="~/CMDBUG1/ext/ext-all.js"></script>
< script src="~/CMDBUG1/app.js"></script>
But it's throwing this error:
TypeError: Ext.application is not a function
If you need more details, let me know!
Any help will be appreciated!
There is no need to set .js and .css to _Layout.cshtml. When you build your application using Sencha CMD you get index.html, app.js, resources/App-all.css and some images. The goal here is that this app can work anywhere on app domain (or other domain if CORS is applied). Web Api will provide URI's your app will call. This way you decouple client app (extjs) from server (webapi) even if they are in same project.And the whole thing will work if you for instance provide different webapi for your application. One thing to bear in mind is baseUri. While you are developing it will be http://localhost:xxxx and when app is deployed it will http://www.somedomain.com. I use simple singleton class where i set my dev and production paths(s). This is necessary so your ajax calls from models/stores/ext.ajax have a valid path to your api. General goal is to decouple client and webapi. You can put your builded app to /app folder and keep your extjs code inside /source folder which you can then exclude from publishing.
Ext.define('MyApp.config.AppConfig', {
statics: {
path: 'http://localhost:8888'
//path: 'http://client1.azurewebsites.net',
//path: 'http://client2.azurewebsites.net'
}
});
and then when calling api you say: url: MyApp.config.AppConfig.path + /users/list. This can be done nicely of course.

Magento : How to hide the default Store View code from the url

The site has 2 languages: English and French, represented by 2 store views. French is the default one. For our SEO efforts we need to have the following urls:
French - http://www.domain.com/category/product
English - http://www.domain.com/en/category/product
System -> Configuration -> Web -> Add Store Codes to URL is the all or nothing setting. We just need to turn it off for the default store only.
I’ve done a lot of searching through the forums and wiki but there’s nothing on the subject.
Please any sugestions?
Finnaly i solved this magic probleme , i hope that's save others persone here is the details :
1- Download the zip existe in this page : https://github.com/Knectar/Magento-Store-Codes
2- unzip the file and put the folder called "Knectar" in {app/code/community/} and Knectar_Storecodes.xml file in {app/etc/modules}
3- In your backoffice go to "System > Tools > Compilation" and click the rebuild button
4- always in backoffice got to "System > Configuration > Web > URL options" and set the attribute "and default store view" to No and save the configuration
5- Clear your cach magento and enjoy your application :) .
I had the same problem and I have developed an extension for that.
It is available on GitHub: https://github.com/jreinke/magento-hide-default-store-code
I didn't find a quick solution to your problem, but I see that's possible through 2 steps :
1 / Using the advise commented by #user3154108 and trying this tip https://magento.stackexchange.com/questions/8126/store-code-in-url-for-every-store-view-except-for-default
2 / For SEO SITEMAP, it's possible to override the following file
app/code/core/Mage/Sitemap/Model/Sitemap.php
public function generateXml()
{
...
}
and replace the default store code by NULL.
For more details try to look at this post : http://alanstorm.com/generating_google_sitemaps_in_magento
I was having the same problem and I had already selected to not show store code in url in the config. I also didn't want to install an extension just to handle something this minor. Here's my EASY solution:
Copy app/code/core/Mage/Catalog/Block/Widget/Link.php to app/code/local/Mage/Catalog/Block/Widget/Link.php
Search for (line 91 in Magento 1.7.x / line 100 in Magento 1.9.x)
$this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
And modify to
$this->_href = $this->_href;
Upload and save your changes and you'll now not have your widget (dynamically) inserted links getting appended with ?___store=default.
Credit: DesignHaven
Under System -> Configuration -> Web -> URL Options you
change "Add Store Code to Urls" to "NO" as on the attached screenshot

Resources