Django Materialize.css Navbar - django

I'm working on a Django webapp and I'm using Materialize for CSS I have placed the Materialize file in the static folder in the app. I have issues with the Navbar that it works fine when in full-screen but when I resize the browser the hamburger icon for mobile navbar doesn't work. When clicked on it, it just goes to the /# page and doesn't openup from the side as it should. Do I have to make any change in the Django or Javscript files files? How can I fix this issue?

Materialize uses a materialize.js file. This file needs to be in your static folders under js. (ie js/materialize.js) You then need to declare this file in your html template after the JQuery script statement as below. Have you done this?
<body>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>

Related

Ember: Application.hbs not generating in body while building

I have a problem with ember-cli build option.
While running server by ember s it's showing normal page with content, styles etc.
But now I want to build this app and put it on my website by ftp so i tried ember build which build my project into /disk folder but the index.html file doesn't contain the stuff from application.hbs + no styles from styles/app.css.
I'm new to ember. What am I doing wrong? Docs of ember are saying nothing about this.
All of your app is actually pulled in through external assets.
So, looking at your pre-built index.html, you'll see something like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>emberclear</title>
{{content-for "head"}}
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/emberclear.css">
{{content-for "head-footer"}}
</head>
<body class='has-navbar-fixed-top'>
{{content-for "body"}}
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/emberclear.js"></script>
{{content-for "body-footer"}}
</body>
</html>
my application is https://emberclear.io, named emberclear, so substitute your app name where applicable.
In the head, we see two link tags.
the first link is for all the styles that your addons may include (maybe such as material-ui, or bootstrap, or bulma).
The second link is your actual app styles. for me, emberclear.css includes everything from app.css, and all of its dependencies (I'm actually using scss, so I can include stuff via scss' #import).
Down in the body we see two script tags.
vendor.js will contain ember itself, and any addon dependencies that need to be included at run time, such as ember-paper's library of components.
emberclear.js includes your app -- routes, templates, etc.
This technique is common for all single page apps, and isn't exclusive to ember. anything built with react, or vue, has a similar pattern.
If you're wanting to have html and css be a part of your index.html, fastboot (https://www.ember-fastboot.com/) + prember (pre-rendered ember: https://github.com/ef4/prember ) may be of interest to you.
Hope this helps! :)
If something is wrong, feel free to copy your built index.html from dist (and maybe additional files as well).
Some follow up questions for you, depending on the issues you are running in to:
Are you getting any errors?
What happens when you try to open the dist/index.html file locally?
You're uploading the contents of dist to an ftp folder. This in-of-itself is fine, but has the web-sever been told to use that ftp folder for a website?
How are you attempting to access the ftp folder via browser?
Maybe there is a domain/path we could look at to see additional details?

django and bootstrap carousel - use offline

I am using bootstrap offline with :
{% load bootstrap3 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
in my template, but the code for the first carousel shown here http://www.w3schools.com/bootstrap/bootstrap_grid_basic.asp
does not work unless I have the CDN links:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
what {% %} do I need to make carousel work ?
Ok.. I have got the answer for Offline Carousel for bootstrap.
Download > jquery slim build (https://code.jquery.com/jquery-3.3.1.slim.js)
Copy the contents in your own File as JS file (like copy paste codes in your file and save as jquery.js)
Link your script inside body tag (before body tag ends) like...<script src="jquery.js"></script>
Finally link bootstrap js file as step 3.
Thank You!
From looking at the documentation, it does not appear that you can use Bootstrap features offline by default. If you look at the default settings for django-bootstrap3, you will see that this package does use the CDNs behind the scenes.
As far as I know, the only way to use bootstrap offline would be to have a copy of the Bootstrap css and JavaScript files saved on your local machine, as well as the jQuery files, since the Bootstrap JavaScript plugins depend on that.
I have not used django-bootstrap3 but it looks like if you have a copy of the necessary Bootstrap files stored locally, you should be able to update your Django settings for django-bootstrap3 to point to these local copies instead of the copies on the various CDNs.

Using polymer-dart with html generated server-side by Django

The dart-polymer transformer assumes that your html are static assets. But I want my html to be dynamically generated server-side. The reason for this is that I want to build a multi-page web-app (or perhaps I should call it a multi-app web-site), and use server-side templating to keep the page structure between pages.
Is there a way to use dart-polymer without using the "compiled" html produced by the polymer transformer? Ideally I want to serve a page like this from the server:
<!DOCTYPE html>
<html>
<head>
<script src="packages/browser/dart.js"></script>
<script type="application/dart"
src="packages/web_components/webcomponents.dart"></script>
<title>Films</title>
<link rel="stylesheet" href="style.css"/>
<link rel="import" href="player/film_player.html"/>
<link rel="import" href="filmlist/film_list.html"/>
</head>
<body>
<film-player id="player"></film-player>
<film-list href="/api/movies"></film-list>
<script type="application/dart" src="main.dart"></script>
</body>
</html>
I know it is not supported having dart.js at the top, but it would be nice if dart.js did as webcompontents.dart.js need to run before the html import tags. At least I guess it does.
I really would like to avoid all the javascript and css inlining done by polymer transformer.
Polymer.dart doesn't support that scenario.
I'm not sure I understand your multi-page attempt. Dart is much better used for single-page application where you dynamically change what is shown at the current page. If you navigate to other pages a whole new Dart application is loaded and you don't have access to variables of the previous page and it is slow because Dart has some overhead and that only pays off if you stick to the one page.
A typical Dart application is built so that the client is basically an entire application that communicates with one or more servers but only sends and receives data but not application logic or views (except for very specific use cases).
Dart supports lazy loading to not load the entire application at once but not yet for Polymer.

Javascript not working? Zurb Foundation accordion issue

So im using zurb foundation framework and something is really weird. On my local server, everything is working fine, however, when I upload the files to my online test server, the accordion drop downs will not work (under courses). Also, my 's for header do not seem to be loading in the html. The main thing is the accordions, as well as if you load it on mobile phone, the menu drop down will not work. Is this a javascript/jquery issue or is there something else going on?
the site can be viewed at http://www.new.omegadesignla.com which is where I'm hosting for testing.
Either load each plugin individually, or include foundation.min.js, which automatically loads the Foundation Core and all JavaScript plugins.
<script src="/js/foundation.min.js"></script>
<!-- or individually -->
<script src="/js/foundation.js"></script>
<script src="/js/foundation.alert.js"></script>
<!-- ... -->
<script src="/js/foundation.dropdown.js"></script>
<script src="/js/foundation.tab.js"></script>

Customize baseUrl and baseDir in CKFinder

We use CKEditor and CKFinder for Coldfusion in many of our CMS applications. These apps point to different sites on our server, so we want CKFinder setup to upload files to directories specific to each app. But we one want one shared location for the CKEditor and CKFinder files on the server.
In the config.cfm file, we have setup the default baseURL and baseDir like this:
config.baseUrl = "http://www.oursite.com/_files/site1/ckfinder_uploads/";
config.baseDir = '\\ourserver01\_files\site1\ckfinder_uploads\';
In the header file for each app, we include the following to instantiate CKEditor and CKFinder (including the jQuery adapter):
<script type="text/javascript" src="/shared/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/shared/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript" src="/shared/ckfinder/ckfinder.js"></script>
<script type="text/javascript">
$(document).ready(function(){
CKFinder.setupCKEditor( null, '/shared/ckfinder/' );
});
</script>
When I open a CKFinder window in one of the apps, it correctly opens to the default baseURL/baseDir. However, how can I override those defaults? I tried changing the CKFinder setupCKEditor function to the following with no luck:
CKFinder.setupCKEditor( null, { basePath:'/shared/ckfinder/', baseUrl:"http://www.oursite.com/_files/NEWSITE/ckfinder_uploads/", baseDir:"\\\\ourserver01\\_files\\NEWSITE\\ckfinder_uploads\\" } );
It just ignored this and used the defaults. Thoughts? Thanks!!
Here's what I did. It's not perfect, but it works. With CF, there's a config.cfm file in the CKFinder directory where you set baseUrl and baseDir. There, I set the value of these two variables to two corresponding browser cookies. Then I set the cookie values in the headers of the different apps, so that they can reflect the app I'm in.
The downside is if you have 2 apps open, only the one you opened most recently will have the correct cookie values set. If anyone knows of a better, similar (or not similar) way of doing this, I'd be interested.
Thanks!
Nick