Copy static files from one Jekyll post to published site - file

I would like to copy any static file (image, PDF, etc.) found in a post folder inside _posts to the folder in which the HTML version of the post will be, inside _site.
Let's say I have this structure:
_posts/
2016/
06/
09-so-long-cloudflare/
2016-06-09-so-long-cloudflare-and-thanks-for-all-the-fissh.md
cloudflare-logo.png
performance-report-sample.pdf
My Jekyll settings for permalinks are:
# Permalinks
permalink: /:year/:month/:day/:title/
I would like to generate the site like this:
2016/
06/
09/
so-long-cloudflare-and-thanks-for-all-the-fissh/
index.html
cloudflare-logo.png
performance-report-sample.pdf
I've found this plugin that should do this, but I can't make it work. I get this error:
jekyll 3.1.6 | Error: undefined method `name' for #<Jekyll::Document:0x007fb7a0892b50>
Any idea?
Thanks!

Well, despite having no Ruby knowledge, I managed to build a plugin out of this old Gist! \o/
https://nhoizey.github.io/jekyll_post_files/
I hope this will help people with the same needs.

Related

adding a page bundle with `hugo new`

I can add a new page with hugo new posts/new-page. But I want to add a page bundle. None of the following work
hugo new posts/2021/10/new-page creates a single new-page.md
hugo new posts/2021/10/new-page/ does the same as above
hugo new posts/2021/10/new-page/index.md works, kind. It creates index.md in the correct path and populates index.md with the archetypes/default.md except, it set the title to index instead of new page
so, how can I add a page bundle with hugo new
You can achieve that using Archetypes , quoting from the docs:
Since Hugo 0.49 you can use complete directories as archetype templates.
in the archetypes/ folder create a new folder named post-bundle/
inside it create a new file index.md
archetypes/post-bundle/index.md :
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---
Then to create a page bundle:
hugo new --kind post-bundle posts/new-page
Notice: I don't think the approach you're doing to set the date in the url is correct , the above method will give a post with the following Permalink : example.com/posts/new-page you can then do the following to get the desired Permalink:
config.toml :
[permalinks]
posts = '/:year/:month/:title/'
In support of Mossab's answer...
a page bundle has three categories:
Branch,
headless
and leaf.
So if you made a file _index.md - it's a Branch bundle, off-the-bat. So viola that's how you make it with hugo new.
If you want a headless bundle, I believe you first need a leaf bundle, and then add:
headless = true to the front matter.
If you want a lead bundle you create an index.md file at any directory level.
So, I believe my point in this is, the way you do this is:
hugo new _index.md
Or
hugo new index.md
and if you want it headless, you use an archetype with the front matter (as Mossab desribes).
Please let me know if I'm possibly misunderstanding something.

Visualforce: Can't access archived static resource

I'm trying to access some static resource in my visualforce page. I have uploaded a zip file named pqGrid. It's structure is like so:
- pqgrid.min.js
- pggrid.min.css
- images/
--image1.png
--image2.png
Following the directions in the sf docs on [referencing a static resource1, I tried the following:
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.css')}"/>
Onloading the page, I get a 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.js
404 (Not Found)
GET https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.css
I've even tried just referencing an image:
<apex:image url="{!URLFOR($Resource.pqGrid, 'images/cross.png')}"/>
and same 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/images/cross.png
404 (Not Found)
I've made sure that the resource cache control is public
What am I doing incorrectly?
EDIT
Tried putting all the files into another directory, so it is now pqGrid/stash/[*files]
When I get the 404 not found:
GET
https://c.cs10.visual.force.com/resource/1430434594000/pqGrid/stash/pqgrid.min.css
I tried playing with this url. Trying to navigate to just /stash/ throws a ERR_INVALID_RESPONSE error. Navigating to just /pqGrid/ let's me download the stuff. Trying to go directly to the file, /pqGrid/stash/file.js I just get a blank page.
So the zip is definitely on salesforce, but something is up with accessing it.
Thanks all!
This happens when we specify incorrect paths for our files would suggest to try below
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.css')}"/>
Sometimes forgetting slash also introduces issues
<apex:includeScript value="{!URLFOR($Resource.pqGrid, '/pqgrid.min.js')}"/>

Using Fat-Free PHP for Backbone.js routing with external Model.php files

I'm very new to Fat-Free and Backbone.js. I've been searching and reading articles and searching and reading articles trying to find a way to route to individual PHP files containing the database communications. The code below works, and I can use it, but it seems hackish. Is there a way to call an external PHP file (in the server/models/ directory) and a specific method from the $f3-route(...) line?
<?php
// File: /index.php
define("PATH",1);
$f3 = require('server/fatfree/lib/base.php');
$uri = explode('/', $_SERVER["REQUEST_URI"]);
require_once "server/models/{$uri[PATH]}.php";
$f3->route('GET /hello/#file', 'HelloModel->doSomething');
$f3->route('GET /project/#file', 'ProjectModel->doSomething');
$f3->route('GET /book/#file', 'BookModel->doSomething');
$f3->run();
?>
Thanks a lot for your advice.
You should add the server/models directory to the autoloader of F3 using the autoloader feature.
$f3->set('AUTOLOAD','server/models/');
That way, the required source files of your classes will be loaded on demand. However, note that the files must be named the same as your class, i.e. class Foo has to be defined in foo.php or Foo.php. The case of the filename does not matter.

CakePHP 2.1 new install Missing Controller Error

I am completely new to CakePHP and installed 2.1. I am getting this error:
Missing Controller
Error: Index.phpController could not be found.
Error: Create the class Index.phpController below in file: app\Controller\Index.phpController.php
<?php
class Index.phpController extends AppController {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_controller.ctp
Stack Trace
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOT\index.php line 40 → require(string)
I followed their guide at http://book.cakephp.org/2.0/en/installation/advanced-installation.html and tried everything it stated:
I enabled mod_rewrites (they were already enabled from something else)
I have all the .htaccess files in the directories
I have cake installed under my document root so I access it at localhost/cakephp/index.php
I do not know where to proceed from here. Thanks for any help you can give me.
Update: I just re-read your question and realized you're loading http://localhost/cakephp/index.php. Don't do that. Since you appended "index.php", it is trying to load a controller called "index.php" and the action "index" for that controller. Resulting mapped path to the "index.php controller" is app\Controller\Index.phpController.php.
Since you have the rewrites enabled, browse to http://localhost/cakephp without appending any filename.
Original answer:
Assuming you're using Apache, double-check the .htaccess in your /app/webroot directory. It should include the following:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Based on your error, it doesn't look like it's properly appending the path after your index.php file.
If you are using cakephp 2.0 or greater than rename the controller file name as the class name.
ie TaskController.php
class TasksController extends AppController {
--Your code inside class
}
I hope this will help you
the easiest solution is to stick to the "live environment" as close as possible.
this means using vhosts to use a "domain" and correctly root down to your webroot dir:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
this leaves almost no room for error and also helps with other potential problems like "absolutely linked asset files" etc

Getting 404 error following Tipfy's Hello World tutorial

I'm sure I am missing something embarrassingly obvious here, but as I am following Tipfy's Hello World tutorial, I'm getting nothing but Werkzeug's 404 page whenever I try to load one of the URLs defined in my urls.py file (in /project/app/apps/hello_world).
I've ensured that 'apps.hello_world' is in the list of installed apps in the 'apps_installed' dictionary in config.py. Everything else seems to be in order, and I've read & followed the instructions in the tutorial and Getting Started guide carefully, but I can't see why Tipfy isn't detecting the rules I defined in get_rules() in my hello_world app's urls.py file.
Here is the code from that file:
from tipfy import Rule
def get_rules(app):
rules = [
Rule('/', endpoint='hello/world', handler='handlers.HelloWorldHandler'),
Rule('/hello-jinja', endpoint='hello/jinja', handler='handlers.HelloJinjaHandler'),
Rule('/hello-json', endpoint='hello/json', handler='handlers.HelloJsonHandler'),
Rule('/hello-ajax', endpoint='hello/ajax', handler='handlers.HelloAjaxHandler'),
]
return rules
Any help anyone can offer is greatly appreciated - thanks!
Nevermind. I solved it. Although it was nowhere in the Tipfy documentation that I could find, and despite the fact that I'm still a solid newbie with Python, I guess I should have known that my 'hello_world' directory in the apps directory needed an __init__.py file in order to be treated as a module

Resources