Customize baseUrl and baseDir in CKFinder - coldfusion

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

Related

Find download URL from datatables "CSV" button?

This R Shiny application appears to use DT to display its tables. At least in the source code I see:
<script src="plotly-binding-4.10.0/plotly.js"></script>
<link href="datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet" />
<script src="datatables-binding-0.20/datatables.js"></script>
<link href="crosstalk-1.2.0/css/crosstalk.min.css" rel="stylesheet" />
<script src="crosstalk-1.2.0/js/crosstalk.min.js"></script>
It also has a "CSV" button to download the data:
How do I download the data from this website myself without clicking? I suppose the button runs some javascript, which makes a network call, but the "network" tab of the chrome debugger doesn't show any activity.
Ideally I could find a URL to the data, and then I could use the language of my choice (e.g., wget, curl, python, ..).
Looks like the raw data are coming from here via the project github. Seems like git pull could do it for you pretty easily.
https://github.com/Metropolitan-Council/covid-poops/blob/main/R/d_covid_cases.R
https://static.usafacts.org/public/data/covid-19/covid_confirmed_usafacts.csv?_ga=2.86006619.233414847.1642517751-2016304881.1642174657
And the other data are in this repo.
https://github.com/Metropolitan-Council/covid-poops/tree/main/data
I was able to use the python requests library to pull the raw data.
import requests
x = requests.get('https://static.usafacts.org/public/data/covid-19/covid_confirmed_usafacts.csv?_ga=2.86006619.233414847.1642517751-2016304881.1642174657')
print(x.text)
Edit: It looks like the shiny data are coming from here. I would just grab them via git. The github readme states, "The Shiny app is located in ./metc-wastewater-covid-monitor. /data contains relevant CSV data and /www contains CSS, HTML, and relevant font files the app needs upon running."
https://github.com/Metropolitan-Council/covid-poops/tree/main/metc-wastewater-covid-monitor/data
You can write a script to use a headerless browser to navigate to the page and download the file. Selenium is the usual first choice for this kind of work.

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 Materialize.css Navbar

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>

pass environment variable from django to react app

I would like to pass a variable from django to react app. I know I can do it by passing window object from html page but I would like to know if its possible to do it using environment variable. I came across this link How can I pass a variable from 'outside' to a react app? which mentions using .env file. Please advise on how it can be used with Django/Python setup.
Just render it into a script tag in your template:
<script type="text/javascript">
var globallyVisibleVar = {myVar}
</script>
But you will have to make sure, that the variable is JSON serialized. You could either write a template tag or JSON serialize it before passing it to the template context. Also make sure to use var and not const or let because they are block scoped and will not be globally visible in your react app.
As the documentation of create-react-app says:
The environment variables are embedded during the build time. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like described here. Alternatively you can rebuild the app on the server anytime you change them.
Since you do not want to rebiuld your whole JavaScript on every request you can't use that to share dynamic data between your server application (Django) and your client application (react).
So if you follow the link you will read this:
Injecting Data from the Server into the Page
Similarly to the previous section, you can leave some placeholders in
the HTML that inject global variables, for example:
<!doctype html>
<html lang="en">
<head>
<script>
window.SERVER_DATA = __SERVER_DATA__;
</script>
Then, on the server, you can replace __SERVER_DATA__ with a JSON of
real data right before sending the response. The client code can then
read window.SERVER_DATA to use it. Make sure to sanitize the JSON
before sending it to the client as it makes your app vulnerable to XSS
attacks.

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>