So I recently started blogging with Pelican, and everything is going great with the exception of Google Analytics. I publish my blog using the
make s3_upload
command, which uses the publishconf.py file.
To get my Tracking ID, all I did was copy paste my Tracking ID from the google analytics page into the Google Analytics line in the publishconf.py file, like so
# Following items are often useful when publishing
#DISQUS_SITENAME = ""
GOOGLE_ANALYTICS = "UA-########-#"
Any help would be greatly appreciated, I have been racking my brain trying to solve the problem.
Solution
editing publishconf.py
GOOGLE_ANALYTICS = "UA-########-#"
Building the website
pelican content
Modifying the website according to settings = adding google analytics
pelican -s publishconf.py .
Deploying
cd output && git push origin master
Tests that the steps work:
Locally at the end of output/index.html it added:
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-125105451-1', 'auto');
ga('send', 'pageview');
</script>
Check that the javascript code has been addded to your github repo. Check that the code is serve in a " private navigation " ( in order to disable browser caching). Right click on your webpage > see source.
Context: Deployment to github pages
Git for the blog:
cd output/
git init .
git remote add origin git#github.com:<username>/<username>.github.io.git
# Deploy with:
# git add . && git commit -m "Commit description" && git push origin master
Git for the blog engine:
cd output && cd .. # ensure to be in the good repository
git init .
git submodule add git#github.com:<username>/<username>.github.io.git output/
If the Analytics snippet is not in the output for your site, it's likely the theme you're using didn't include the proper code to include it.
Each theme should have a base.html file, you should look at that to make sure it's included there. If not you can add something like:
{% if GOOGLE_ANALYTICS %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{GOOGLE_ANALYTICS}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{GOOGLE_ANALYTICS}}');
</script>
{% endif %}
Related
WSO2 API Manager is saving hundreds of 'publisher' HTML files (every day) to directory "/root"
All of the files have names like:
publisher.1
publisher.2
publisher.3
...
publisher.978
etc
How do I stop it from creating these files, or atleast how can I change the output directory for the files?
The contents of each file is HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var requestURL = '/publisher';
var ssoEnabled = 'false';
var tenantDomain = 'null';
</script>
<title>API Publisher- Login</title>
<meta charset="UTF-8">
...
...
...
<script>
var siteRoot = '/publisher/site/themes/wso2';
</script>
<script type="text/javascript" src="/publisher/site/themes/wso2/libs/jquery.cookie.js"></script>
<script type="text/javascript" src="/publisher/site/themes/wso2/templates/utils/button-loader/jquery.buttonLoader.js"></script>
</body>
</html>
Looked in a bunch of config files, and in carbon management settings, but can't find anything that looks like it controls this.
Expect no html files to be saved at all to root directory.
By going through the file content you have given, It seems, it's a rendered output of a publisher page.
Because the following script tag is coming from the base template in WSO2 API Manager publisher app.
<script>
var requestURL = '/publisher';
var ssoEnabled = 'false';
var tenantDomain = 'null';
</script>
But there is no possibility to write the rendered HTML pages to /root/ directory or to anywhere else in the file system.
And also by default (In Unix systems), only root user has Read, Write permission to the /root/ directory. So unless you run a tool with root permission, It can't write files to the /root/ directory.
WSO2 API Manager does not need root permission to run nor it's recommended to start the server with superuser privileges.
So I think, this should have done by some external tool.
For example: If you have configured a health-check tool to GET a /publisher page and write the snapshot of the page to file system each time you perform the health check and if that is configured to write to /root/ directory this could have happened.
Can you check
Whether these files are created in equal time intervals
Who is the owner of these files (ls -lh)
And also check whether WSO2 API Manager is running with the same user who has created those files (ps -aux | grep wso2server).
I am working with Laravel Event Broadcasting and i am using pusher driver for broadcasting event and its working perfectly.
The public channel is subscribed successfully from client side using pusher provided js library
var pusher = new Pusher('xxxxxxxxxxxxxxxxxxxxx_my_app_key', {
encrypted: true
});
var channel = pusher.subscribe('TestPusher');
channel.bind('App\\Events\\TestPusher', function(data) {
alert(data.msg);
});
But when i use Echo in my client side code
Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
It generates the error " Echo is not defined ".
I already installed the Laravel Echo library using npm install --save laravel-echo pusher-js in my application and also included the following code in resources/assets/js/bootstrap.js file as per the laravel provide documentation.
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'xxxxxxxxxxxxxxxxxxxxx_my_app_key'
});
So please help me how can i fix this problem.
My issue was that I was not compiling bootstrap.js together with the rest of the code because I had removed the line require('./bootstrap') from app.js. I added that line back and I was home and dry.
As described here
I had this problem a few days ago. My gulp installation was all messed up and Laravel versioning didn't help.
Sorry if this doesn't help, it's just my experience and most detailed as possible:
First, I'll consider you do have the js/app.js script included on you site.
Now, you're seeing this error because, as Josh mentioned, you're not compiling your js files. After editing 'resources/assets/js/bootstrap.js', this file needs to be compiled by running the asset compiler: gulp (named Laravel Elixir docs/5.3/elixir) in Laravel 5.3).
If you followed carefully this part of the tutorials, you shall be extra careful with laravel's npm dependencies versions, specially those used by Elixir (Once again, my gulp installation wasn't working at all even though no error messages showed up).
So, if this is a new project, you should consider updating to Laravel 5.4. If you can't or not willing to update all Laravel framework, perhaps this can be solved like I did. Staying at 5.3 but using the latest assets compiler on 5.4, named Laravel Mix. Now it runs on npm: npm run dev. (No gulp mentioned on doc.)
To achieve this, you should update to latest package.json on 5.4 and follow the 5.4 documentation to install Laravel Mix.
Your codes looks fine, Problem is your JS order so only you getting undefined issues
like
<script>
Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
</script>
<script src="echo.js"></script>
so zigzag the order :)
widow object before each Echo.
window.Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
remove defer from your app.js script tag
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
I have an existing ASP.NET MVC web site. www.foo.com
I want to create a whole new sub system of our site using Angular2 and I want it to go under www.foo.com/NewSubSystem.
I have downloaded the Angular2 Cli from https://cli.angular.io/.
When I run from the command line
ng build -dev
The output has all the javascript script tags looking this in the index.html file
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>
I need the scr="www.foo.com/NewSubSystem/inline.bundle.js"
NOTE: I have tried to update the baseURL in the tsconfig.json
"compilerOptions": {
"baseUrl": "www.foo.com/NewSubSystem"
}
but this does not seem to make any difference.
Any suggestions or pointers would be nice. Thanks
Set the index file baseref
base href="NewSubSystem/"
Then just code like its the root.
I reset the baseref to dist/ with javascript depending on the env sensed
Change your index.js files update
<base href="/<you base url>/">
if you are working with webpack:
You should also update the file config/webpack.common.js, so that you assets folder content can be hosted from your new baseurl.
...
const METADATA = {
title: 'ng2-admin - Angular 2 Admin Template',
description: 'Free Angular 2 and Bootstrap 4 Admin Template',
baseUrl: '/<you base url>/',
isDevServer: helpers.isWebpackDevServer()
};
.....
This is happening on my development machine and the same codebase is working in production. So I believe this to be an IIS/Framework issue. It affects all pages.
On both servers, the Page_Validators are setup correctly:
<script type="text/javascript">
<!--
var Page_Validators = new Array(document.getElementById("ValidatorInsurancePayerRequired"),
document.getElementById("ValidatorCheckPostDateRequired"),
document.getElementById("ValidatorCheckPostDateFormat"),
document.getElementById("ValidatorCheckNumberRequired"),
document.getElementById("ValidatorCheckTotalRequired"),
document.getElementById("ValidatorCheckTotalFormat"));
// -->
</script>
However, on my development machine it does not render the script block that sets the validation properties:
<script type="text/javascript">
<!--
var ValidatorInsurancePayerRequired = document.all ? document.all["ValidatorInsurancePayerRequired"] : document.getElementById("ValidatorInsurancePayerRequired");
ValidatorInsurancePayerRequired.controltovalidate = "txtPayer";
ValidatorInsurancePayerRequired.errormessage = "<br>Insurance Payer Is Required";
ValidatorInsurancePayerRequired.display = "Dynamic";
ValidatorInsurancePayerRequired.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
ValidatorInsurancePayerRequired.initialvalue = "";
.
. all other Page Validators
.
// -->
</script>
I have tried running aspnet_regiis -c to reinstall the validation scripts. Failing that I tried that with a -e (remove) followed by -i (install).
Any ideas?
What versions of .NET/IIS are you running? If this is a 2.0 implementation, try putting this in your web.config in the system.web section and see what happens:
<xhtmlConformance mode="Legacy"/>
Does this happen if you run using the ASP.Net Development Server?
Also, if tracing is enabled in development, try disabling it.
Short of these few suggestions, I'd really need a lot more info on your environments in order to assist further.
i'm currently trying to implement "UPLOADIFY" to a wordpress template page.
I implemented it well, because almost everything is working now, except the Upload doesn't start, but the reason therefore is propably not wordpress.
It's propably the folder I set where i want to upload the files to.
The folder lies in my root of the page and normally i'm connecting to it with an ftp client. If i call the folder in my browser with http://www.mywebsite.com/fileupload the browser tells me forbidden.
However, that's not the only folder which is not working. it doesn't actually matter which folder i'm creating and what permissions i give it, the upload will not start.
<script type="text/javascript">
$(document).ready(function() {
jQuery('#fileselect').uploadify({
'uploader': '<?php bloginfo('template_url'); ?>/uploadify/uploadify.swf',
'script': '<?php bloginfo('template_url'); ?>/uploadify/uploadify.php',
'folder': 'http://www.mydomain.com/test', //or just /test
'multi' : 'true',
'cancelImg': '<?php bloginfo('template_url'); ?>/uploadify/cancel.png'
});
});
</script>
i tried creating a new directory in my root of my website called "test" and i gave it all permissions 777. However the upload will not start.
do you guys have an idea, what i could do wrong? is there a debug mode or so?
please guys help me, i would love to make uploadify working.
in your $(document).ready function you need to add
'auto': true,
Also I would recommend removing the quote from multi since it is a boolean not a string
<script type="text/javascript">
$(document).ready(function() {
jQuery('#fileselect').uploadify({
'uploader': '<?php bloginfo('template_url'); ?>/uploadify/uploadify.swf',
'script': '<?php bloginfo('template_url'); ?>/uploadify/uploadify.php',
'folder': 'http://www.mydomain.com/test', //or just /test
'multi' : true,
'auto' : true,
'cancelImg': '<?php bloginfo('template_url'); ?>/uploadify/cancel.png'
});
});
</script>
I don't know about this addon, but it seems wrong for me that you set the upload folder in the client side, for obvious security reasons.
I'm sure the plugin have some settings on server side, like an array of available accepted upload locations. Besides, if accessing a folder from your browser says forbidden, it's probably due to that server configuration prevent directory listing, and it doesn't mean it's forbidden for the script to write/upload/create files in it.