Issue integrating Netlify CMS with my pelican static website (Error: Failed to load config.yml) - pelican

I’m trying to integrate Netlify CMS to a static Pelican website.
I can’t seem to access /admin as I get the following error:
Error: Failed to load config.yml
Check your config.yml file.
Here is the content of admin/index.html (I followed these instructions)
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head>
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms#^2.0.0/dist/netlify-cms.js"></script>
</body>
</html>
and here is the content of my config.yaml
backend:
name: github-getaway
branch: master
media_folder: "img/uploads" # Folder where user uploaded files should go
public_folder: "uploads"
collections: # A list of collections the CMS should be able to edit
- name: "post" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Article" # Used in the UI, ie.: "New Post"
folder: "content/news" # The path to the folder where the documents are stored
format: markdown
sort: "date:desc" # Default is title:asc
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h2", class: "entry-title"}
- {label: "Body", name: "body", widget: "markdown"}
meta: # Meta data fields. Just like fields, but without any preview element
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Category", name: "category", widget: "string", default: "News"}
if needed, the website’s url is https://distracted-engelbart-20e42f.netlify.com
Any ideas on what I’m doing wrong here?

This post is a few months old so I guess you got this working?
I had to add the admin files to the STATIC_PATHS variable in pelicanconf.py
STATIC_PATHS = [
'admin/index.html',
'admin/config.yml',
'images',
'extra'
]
Here's my example repo with Netlify CMS integrated https://github.com/marcus-clements/pelican-netlify-cms

Related

How to change favicon.ico and page title (Vue + Webpack)?

I have created my project with vue-cli, running 'vue init webpack project-name'. I cannot figure out how to change the page title and the favicon displayed.
Somehow the page title is always 'Vue App' and favicon is the Vue logo. How do I change these? They seems to be generated from somewhere in the webpack config, but I cannot figure out where.
I fixed this by creating a public folder to the project root. Then I moved my index.html and favicon into the public folder.
//This is in the index.html head
<link rel="icon" type="image/png" href="/favicon.png" />
If you're using vue-cli, this is the only way I could find to get the page title to not unprofessionaly flash "Vue App" on load. If someone finds an easier solution, please share!
Create custom-index.html with your own title, then in vue.config.js:
const HTMLWebpackPlugin = require('html-webpack-plugin');
...
plugins: [
new HTMLWebpackPlugin({
showErrors: true,
cache: true,
template: path.resolve(__dirname, 'src/custom-index.html'),
})
],

TemplateDoesNotExist at / home.html

I am trying to get a template to be rendered under my templates folder. I believe I set my views correct, URL settings, and settings for to render the view. However, I keep getting the same error, where the template cannot be found. I keep thinking its a path issue but cant put my finger on the issue. I added my screens of different views of my code.
# In newword/newword/newword/views.py
from django.http import HttpResponse
from django.shortcuts import render
def home(request):
return render(request, 'home.html', {})
# In newword/newword/newword/settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ 'templates/home.html'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
# In newword/newword/newword/urls.py
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home),`enter code here`
]
# In newword/newword/newword/templates/home.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body></body>
</html>
# Error Output
TemplateDoesNotExist at /
home.html
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.1.5
Exception Type: TemplateDoesNotExist
Exception Value:
home.html
Exception Location: /usr/local/lib/python3.7/site-packages/django/template/loader.py in get_template, line 19
Python Executable: /usr/local/opt/python/bin/python3.7
Python Version: 3.7.2
Python Path:
['/Users/robertromulus/pythonProjects/newword/newword',
'/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python37.zip',
'/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7',
'/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload',
'/Users/robertromulus/Library/Python/3.7/lib/python/site-packages',
'/usr/local/lib/python3.7/site-packages']
Server time: Mon, 7 Jan 2019 03:02:48 +0000
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: /Users/robertromulus/pythonProjects/newword/newword/templates/home.html/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/admin/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.7/site-packages/django/contrib/auth/templates/home.html (Source does not exist)
Traceback Switch to copy-and-paste view
/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py in inner
response = get_response(request) ...
▶ Local vars
/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/Users/robertromulus/pythonProjects/newword/newword/newword/views.py in home
return render(request, 'home.html', {}) ...
▶ Local vars
/usr/local/lib/python3.7/site-packages/django/shortcuts.py in render
content = loader.render_to_string(template_name, context, request, using=using)
I want the home.html to be rendered when I go to the root path of the site.
Problem solved - I need to add another folder then templates, and under templates each html file. This video helped. https://www.youtube.com/watch?v=xp_N4JnxHIk&t=184s&list=PLhTjy8cBISEpXc-yjjSW90NgNyPYe7c9_&index=6

Load customized Dojo module

I am really new to Dojo so this may sound dumb.
I am using Dojo 1.7 as a hosted resource (that is, I downloaded the dojo package and put it under the source code). Then I have a customized module defined in another folder. The structure looks like this:
/
libs/
js/
dojo/
dojo.js
myPage/
myModules/
myCustomizedModule.js
index.html
I am using the "define" function to define a module in myPage/myModules/myCustomizedModule.js
In "myPage" folder, I am using index.html to require the customized module:
<script>
require(["myPage/myModules/myCustomizedModule"], function(myCustomizedModule){
// Do something.
})
</script>
However, I can't get it to work: the console reported an error:
"http://localhost/myDojoTest/libs/js/dojo/myPage/MyModules/myCustomizedModule.js 404 (Not found)".
I know this directory is not right since "myPage" folder is not under "libs/js/dojo". But it seems when using the "require" statement, instead of using the relative path of the current HTML document, the code uses the current path for the dojo.js file.
Is there anything I can do to correctly refer to my customized module?
Many thanks!
As per your requirement, you need to set up packages as indicated below
<!-- dojo configuration options -->
<!-- For Package configuration refer tutorial at http://dojotoolkit.org/documentation/tutorials/1.7/modules/ -->
<script type="text/javascript">
var dojoConfig = {
async: true,
baseUrl: "/",
tlmSiblingOfDojo: false,
packages: [
{ name: "dojo", location: "libs/js/dojo" },
{ name: "dijit", location: "libs/js/dijit" },
{ name: "dojox", location: "libs/js/dojox" },
{ name: "myModules", location: "myPage/myModules" }
]
};
</script>
You can than access dojo, dijit and myModules in require function call as.
Remember you need to precede the modules with their respective packages.
<script>
require([
//Require resources.
"dojo/store/Memory",
"myModules/myCustomizedModule"
], function(Memory, myCustomizedModule){
....
}
);
</script>
Hope it helps.

how to load js widget file in dojo ? registerModulePath is working but in 1.8 packages not working - need help immediately

Hello need help immediately,
I have web directory as
- WebContent
index.jsp
dojo
testjs
- bpl
- mywidget.js
Context path is /TestWeb/CheckDojo
script in index.jsp:
dojo.registerModulePath("testjs","/TestWeb/CheckDojo/testjs");
is working and i can do
require([ "dojo/dom", "testjs/bpl/mywidget", "dojo/domReady!"], ...
but in dojo 1.8 ,
in dojoconfig i am using
data-dojo-config="locale: en-us,
async: true,
config-tlmSiblingOfDojo: false,
packages: [{
name: 'testjs',
location: '/TestWeb/CheckDojo/testjs'
}],
parseOnLoad: true"
then in require mywidget is searched in dojo directory which is not the correct path.
what and how should i load the package ?
Look here enter link description here (module indentifiers). The documentation tells that the location is relative of the 'dojo' folder (defined in dojo.baseUrl).
You should change the code to :
data-dojo-config="locale: en-us,
async: true,
config-tlmSiblingOfDojo: false,
packages: [{
name: 'testjs',
location: '../TestWeb/CheckDojo/testjs'
}],
parseOnLoad: true"

Debug CoffeeScript with IntelliJ

I'm starting a fresh web project and the last part of my configuration is to enable debugging for my CoffeeScripts files.
The whole project is build using a Grunt task that compile coffee to js and generates the proper map file but I cannot make the Coffeescript debuging work in IntelliJ.
Note that I don't want to use IntelliJ File Watchers.
Here is my Gruntfile :
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
coffee:
options:
sourceMap: true
files:
expand: true
flatten: true
cwd: 'src/'
src: ['**/*.coffee']
dest: 'src/'
ext: '.js'
concat:
option:
separator: ';'
dist:
src: ['src/**/*.js']
dest: 'dist/<%= pkg.name%>.js'
uglify:
options:
banner: '/*! <%= pkg.name %> v<%= pkg.version%> by Pierre Degand <%= grunt.template.today("dd-mm-yyyy") %> */\n'
dist:
files:
'lib/<%= pkg.name%>.min.js': ['<%= concat.dist.dest %>']
watch:
files: ['<%= coffee.files.src %>']
tasks: ['coffee', 'concat', 'uglify']
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.registerTask('default', ['coffee', 'concat', 'uglify'])
My Simple CoffeeScript file (Break point is on line 2 on IntelliJ) :
name = 'Pierre'
console.log "Hello #{name} !"
Generated JS file from Grunt :
(function() {
var name;
name = 'Pierre';
console.log("Hello " + name + " !!");
}).call(this);
/*
//# sourceMappingURL=app.js.map
*/
The source map
{
"version": 3,
"file": "app.js",
"sourceRoot": "",
"sources": [
"app.coffee"
],
"names": [],
"mappings": "AAAA;CAAA,GAAA,EAAA;;CAAA,CAAA,CAAO,CAAP,IAAA;;CAAA,CACA,CAAA,CAAa,CAAb,EAAO,CAAM;CADb"
}
And finally the html I use to test
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="src/app.js"></script>
</body>
</html>
When I used File watchers, the .js and the .map.js were subfiles of the .coffee file, can I achieve the same behavior without using File Watchers ?
If I right-click/"Debug index.html" in IntelliJ, I can read "Hello Pierre!!" in my IntelliJ debuger console, but the script is not breaked on the console.log()
Did someone had same troubles ?
Thanks!
When I used File watchers, the .js and the .map.js were subfiles of the .coffee file, can I achieve the same behavior without using File Watchers?
No, you can't. This is a file watchers feature
If I right-click/"Debug index.html" in IntelliJ, I can read "Hello Pierre!!" in my IntelliJ debuger console, but the script is not breaked on the console.log()
This works for me if I refresh a page in browser after the code was executed. Please vote for this ticket