-
-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrites rules for dpl-docs file name style change #951
Conversation
MartinNowak
commented
Apr 2, 2015
- add RewriteMap that maps all current modules
- add RewriteMap that maps all current modules
|
Oh dear, I hope this doesn't impact Apache's performance too much. Also, isn't this missing something? A |
|
I generated the file by hacking ddox 0.10.2. diff --git a/source/ddox/htmlgenerator.d b/source/ddox/htmlgenerator.d
index 0491f90..83ac21d 100644
--- a/source/ddox/htmlgenerator.d
+++ b/source/ddox/htmlgenerator.d
@@ -33,6 +33,8 @@ import vibe.templ.diet;
void generateHtmlDocs(Path dst_path, Package root, GeneratorSettings settings = null)
{
+ import std.stdio;
+ auto rewriteMap = File("rewrite_map.txt", "a");
import std.algorithm : splitter;
import vibe.web.common : adjustMethodStyle;
@@ -86,7 +88,7 @@ void generateHtmlDocs(Path dst_path, Package root, GeneratorSettings settings =
return dst.data();
}
- void collectChildren(Entity parent, ref DocGroup[][string] pages)
+ void collectChildren(Entity parent, ref DocGroup[][string] pages, Path modpath)
{
Declaration[] members;
if (auto mod = cast(Module)parent) members = mod.members;
@@ -96,11 +98,13 @@ void generateHtmlDocs(Path dst_path, Package root, GeneratorSettings settings =
foreach (decl; members) {
auto style = settings.fileNameStyle; // workaround for invalid value when directly used inside lamba
auto name = decl.nestedName.splitter(".").map!(n => adjustMethodStyle(n, style)).join(".");
+ if (name != decl.nestedName)
+ rewriteMap.writeln("/", modpath ~ PathEntry(decl.nestedName~".html"), "\t", "/", modpath ~ PathEntry(name~".html"));
auto pl = name in pages;
if (pl && !canFind(*pl, decl.docGroup)) *pl ~= decl.docGroup;
else if (!pl) pages[name] = [decl.docGroup];
- collectChildren(decl, pages);
+ collectChildren(decl, pages, modpath);
}
}
@@ -114,7 +118,7 @@ void generateHtmlDocs(Path dst_path, Package root, GeneratorSettings settings =
generateModulePage(file, root, mod, settings, ent => linkTo(ent, pack_path.length-dst_path.length));
DocGroup[][string] pages;
- collectChildren(mod, pages);
+ collectChildren(mod, pages, modpath.relativeTo(getWorkingDirectory() ~ "web"));
foreach (name, decls; pages) {
auto file = openFile(modpath ~ PathEntry(name~".html"), FileMode.createTrunc);
scope(exit) file.close(); |
|
I checked that it works even though the RedirectMap isn't yet defined, this has to be done in the server config. Need to ask Jan for that. |
|
Don't think it will have a bad impact on performance, it's just a hash table lookup (actually 2 because of the RewriteCond). |
Hmm, that's not ideal... how about a PHP script as a 404 ErrorDocument for /library/? |
To clarify, as I understand that the patch as it is now will error out for all requests until the RedirectMap is added. That means that everyone who wants to host a mirror of the docs will need to modify their server configuration. |
|
Not sure, it just won't perform the redirect, so it stays like it is right now. |
Sorry, what is that in reference to? |
|
No, I just changed the .htaccess to test this, apache will ignore the non-existing map. |
W0rp asked for those redirects, and I noticed myself, that you can easily land on dead pages from a google search. |
|
Try |
|
Yes, I noticed that too, but Google will eventually de-index them. |
But adding permanent redirects will help with that. |
I still don't understand what this means. |
|
That means |
|
OK, let's carefully try this. |
rewrites rules for dpl-docs file name style change
|
I'll update the website and mail Jan with detailed instructions. |
|
Thanks |
Running an update now |
|
(done) |
|
I justed looked at the implementation of httpd (https://github.com/apache/httpd/blob/e7dc8e899a6a942e08784337e827c3772c6bb2b5/modules/mappers/mod_rewrite.c#L1272). |
|
We should at least move this under /library/.htaccess so it doesn't impact the entire site. |
|
Good point. Those dbm files are big, 6M, so we should create them on the server only. |
|
Hmm... I don't think 6MB will make much of a difference. |
|
I just don't want to check this into git. |
|
So don't, why not add a D tool that creates the .dbm file? |
|
(disclaimer: no idea how difficult it actually is to do the above) |
|
Let's just put that file directly on the server - it depends on a server-side configuration anyway. If possible, it should be outside /data/, so that any future rsync --delete doesn't delete it. |
I'd rather sleep.
Right, let me figure out #952 first. |
|
Rewrite rules are active. |