I'm in the process of migrating a fairly old Jekyll 2 to a recent Jekyll 3. I've realized that the default digest algorithm for the assets changed from MD5 to SHA, and that breaks all existing links to assets. For example, if someone shares the post on Facebook, the image URL is cached and will result in a broken image.
I'm trying to set the algorithm back to MD5, but I'm unable to find any usable info googling around. I've learned that assets are handled by jekyll-assets, which uses Sprockets under the hood. I think I need to configure it somehow, but I don't know how to access it via either the _config.yml or from .rb files.
In the current version the algorithm type can't be configured in jekyll-assets, jekyll-assets only have: https://github.com/jekyll/jekyll-assets/blob/master/lib/jekyll/assets/liquid/tag/defaults/sha.rb where it sets:
def set_integrity
digest = Sprockets::DigestUtils.integrity_uri(
Digest::SHA384.digest(
#asset.to_s
)
)
where you would need to use Digest::MD5.
Related
It is well known that nextjs API routes provide a straightforward solution to build your API with Next.js. and that any file inside the folder pages/api is mapped to /api/* and will be treated as an API endpoint instead of a page.
I have just one doubt: is the code within the pages/api exposed to the world? I mean, can I build some logic there that has some key that must be hidden or maybe some MySQL connection?
Whether or not /api is in any way exposed to the world I do not know for sure, but according to Next documentation, "they are server-side only bundles."
In general though, for any key/sql connection that you want to run, I would put that into an .env.local file on your machine, a file that gets git ignored and never uploaded, and if you are hosting on Vercel, then use their environmental variables to store sensitive information.
You'd find environmental variables under:
{Your Account}/{Project}/Settings/Environmental Variables
p.s. Also from Next.js docs, I think you'd find this bit on getStaticProps useful.
I have a simple use case on a site that I am publishing with Jekyll:
I need to list values of a certain type. Let's say one type has URIs of the form .../base/typex/value. I am generating a file .../typex/value.md and Jekyll happily serves it.
I also want to serve pages listing all values. That page should be named .../base/typex or .../base/typex/ (I don't mind either way).
I cannot use the file .../base/typex/index.md to do this because in some cases, index is actually a valid value.
I am creating .../base/typex.md, but Jekyll ignores it, regardless of the permalink that I put in there that specifically has no trailing slash. Instead of serving the file, Jekyll serves the directory listing.
Is there any way I can solve this puzzle? If Jekyll had support for serving .../base/typex.md, everything would be good, but it seems as if as soon as there is a directory .../base/typex/, Jekyll simply ignores this file. Is there any workaround or configuration I can use? (And this is going to get hosted on GitHub, so I have no control over the Web server configuration.)
( https://github.com/dret/webconcepts/issues/25 has the backstory, in case anybody is interested. But the issue is fully described here, so there is no need to follow that link. )
I just tried to reproduce it with your provided repository, thanks for that!
If you create a file http-method.md in /concepts and set the permalink to
permalink: /concepts/http-method/, my local jekyll serves the page both in /concepts/http-method and /concepts/http-method/
Using html import 2 plugin for wordpress, I've gathered a list of old file-paths and what they've been changed to.
Instead of bulking up my .htaccess with redirects, I was hoping there was a way to replace all the old links with the new ones.
For instance, i have a list:
oldlink1, newlink1
oldlink2, newlink2
oldlink3, newlink3
oldlink4, newlink4
and I want to replace every occurence of oldlink1 with newlink1. possible?
Are you asking about file and images paths in the post content? (1) Or are you asking about post permalinks to redirect the old .html URLs to new WordPress URLs without the .html suffix? (2)
1) For file image paths in post content, probably the easiest and most foolproof approach is to use a find/replace plugin that will provide a front end to the database so you don't run queries directly on the database.
Try http://wordpress.org/plugins/search-regex/ With it, you can find/replace post content, post meta, comment content, etc.
Search Regex adds a powerful set of search and replace functions to
WordPress. These go beyond the standard searching capabilities, and
allow you to search and replace almost any data stored on your site.
In addition to simple searches you have the full power of PHP's
regular expressions at your disposal.
2) For URL redirects, you can try http://wordpress.org/plugins/redirection/ which will allow a CSV import of URL redirects while logging 404s and redirects.
Redirection is a WordPress plugin to manage 301 redirections and keep
track of 404 errors without requiring knowledge of Apache .htaccess
files.... This is particularly useful if you are migrating pages from
an old website, or are changing the directory of your WordPress
installation.
With this script you can do a search & replace on your WordPress database. Just follow the instructions, and don't forget to remove the script after you're done.
I am currently exploring Octopress. One question popped up during the course of my work - is there an easy way to publish a post from a random computer/device. I mean - if I do this via rake new_post['title'] I must have the whole thing set up on the machine I am doing it from - Ruby, gems etc.. Is there an easier way - like create a markdown document and than just send it to the Github repository?
I think there is no way to do that.
Since octopress is based on Jekyll, every page is rendered as follows:
Render Liquid
Convert if a converter exists for that extname(e.g. .markdown)
Render layout(s) recursively.
That is to say, for such a static website, it's unable to show a markdown document directly.
On the other hand, if what we send to repo is not a markdown file which must be converted to html to be showed, but a html directly, it's also not possible to make the site work normally.
Since not only the post page itself should be generated, but also many related parts such as index page, categories and so on.
In one word, octopress is static, we need generation before deployment.
Reference:Allow markdown to not be compiled to html
I have switched to Ruby on Rails and my current problem is to reroute
the old contents like XXX/dummy.html or XXX/dummy.php in RoR.
What exactly is the best solution for
isolated content (XXX/onlyinstance.html)
content which has a internal structure like XXX/dummy1.html, XXX/dummy2.html
http://guides.rubyonrails.org/routing.html does not explain how to
migrate old content.
Note: Changing the old links is NOT an option. The website is hosted, it is not my
own server. As the domain hasn't changed, the solution to redirect it seems to be
unnecessary...there should be a better solution.
EDIT: I have found out that the best solution is in fact rerouting it by the way weppos described.
So add a .htaccess file in the public directory
and write
RewriteEngine on
Redirect permanent /XXX.php http://XYZ/XXX
For whatever reason, RoR did not accept rerouting in routes.rb...while .html/.xml
all goes fine, .php does not function. I haven't found out why. Because weppos answer
was the best, I will award him a 50 point bounty, but as the others answers are valid,
too, I will upvote them. Thank you all
You can do this in multiple ways.
The best and most efficient way is to use your front end web server.
You can easily setup some configurations in order to redirect all the old URLs to the new ones.
With Apache, you can use mod_alias and mod_rewrite.
Redirect /XXX/onlyinstance.html /new/path
RedirectMatch ˆ/XXX/dummy([\d])+\.html$ /new/path/$1
This is the most efficient way both for server and client because handled at server level without the need to initialize the Ruby interpreter.
If you can't/wan't take advantage of server settings, you can decide to use Rails itself.
Talking about performance, the most efficient way is to use a Rack middleware which is much more efficient than creating a full controller/action.
class Redirector
def self.call(env)
if env["PATH_INFO"] =~ %r{XXX/onlyinstance\.html}
[301, {"Content-Type" => "text/html", "Location" => "http://host/new/path/"}, "Redirecting"]
else
[404, {"Content-Type" => "text/html"}, "Not Found"]
end
end
end
There is also a Rack plugin called Redirect that provides a nice DLS for configuring redirects using a Rack middleware.
Just a footnote. I won't creating additional routes using routes.rb because you'll end up duplicating your site URLs and wasting additional memory.
See also Redirect non-www requests to www urls in Rails
What do you mean by migrating? I recommend to redirect clients to use the RoR URLs. This can be done using HTTP 301 status codes. See http://en.wikipedia.org/wiki/HTTP_301:
The HTTP response status code 301 Moved Permanently is used for permanent redirection.
This can be done in the configuration of your HTTP server.
You have to redefine your application since Rails uses RESTful routing (as you probably have read). So in order to have a php file which handles show, creating,destroying, etc of items, you need to build a item Model, Controller and views for the different actions.
The static HTML files you can copy to the public directory, since that is the same. The structure you used can still be the same.
In order to modify your routing you have to add map.resource to your config/routes.rb file. This implements the RESTful routes to your controller. To start use the webserver provided by Rails (WEBrick), by entering the script/server command. Later when you have more experience you could think of switching to another server if WEBrick is not sufficient.
I suggest you start writing a basic (blog) application with Rails first, see here. So you see what parts is Rails using and how you can use them.
Afterwards you are able to identify these parts in you PHP solution and are bbetter capable to convert your pages. At least I followed this approach when I started to use/convert to Rails from PHP.