flobrosch / valadoc-org

32 stars 5 forks source link

Links always redirect to home #56

Closed danirabbit closed 7 years ago

danirabbit commented 8 years ago

Seems like links are totally broken right now. Any links from other websites to specific pages always redirect to the index

btkostner commented 8 years ago

Should be fixed with this guy https://github.com/flobrosch/valadoc-org/pull/60

ghost commented 8 years ago

I can confirm that this issue persists on the valadoc.org website, I'll try to replicate the issue on a local build later.

Update: On my local build, pasting links (or opening links in a new tab) gives me a 404 error page. It's possible that I'm missing a step somewhere, but either way the local copy doesn't seem to work either.

tpimh commented 8 years ago

This is pretty annoying because middle-clicking anything doesn't work as expected.

btkostner commented 8 years ago

Ok, so after a bit more testing on the local branch, that PR does fix the refreshing issue and links from other pages AS LONG AS the link includes the hash http://localhost:7777/#!api=gio-2.0/GLib vs http://localhost:7777/gio-2.0/GLib.html. Sadly all the static links on the page are something like http://localhost:7777/glib-2.0/index.htm so they will return a 404.

I'll see what I can do about more rewriting of the common url :8ball:

alsoijw commented 8 years ago

After middle click or copy and paste url to address bar I got 404 error.

ZanderBrown commented 8 years ago

some fixes have been merged but they haven't made it to the live site yet.

alsoijw commented 8 years ago

When will it be ready?

ZanderBrown commented 8 years ago

no idea. nothing to do with me. ask @flobrosch i suppose

roojs commented 8 years ago

Looks pretty messy - the code in git does not appear to work

I suggest, as good practice, do not modify input variables (eg. _GET/_POST etc.. -> since page=* comes from .htaccess - it's probably worth just rewriting that as the hashbang url and redirecting ... otherwise it just get's messy trying to work out the logic..

This fix + replace reference sto _GET[page] with $page/$GLOBALS['page'] should work.

fixed on valadoc.roojs.com for the time being.

<?php
//      ini_set("display_errors","1");
//      ERROR_REPORTING(E_ALL);

if ( isset($_GET['page']) && $_GET['page'] == '' ) {
//  $_GET['page'] = 'index.htm';
}
if(!empty($_GET['page'])) {
        header('Location: /index.php#!api='.preg_replace('/\.html$/','', $_GET['page']));exit;
}
$page = 'index.html';

$hash_frag = isset($_GET['_escaped_fragment_']) ? htmlentities($_GET['_escaped_fragment_'], ENT_QUOTES, 'UTF-8') : false;
if ( $hash_frag !== false ) {
  if ($hash_frag == '') {
    $page = 'index.htm';
  } else {
    $parts = explode ('=', $hash_frag);
    $key = $parts[0];
    $value = $parts[1];
    if ($key == 'wiki') {
      $page = $value.".htm";
    } else if ($key == 'api') {
      $page = $value.".html";
    } else {
      $page = 'index.htm';
    }
  }
}

Note that $page is not very well protected - although it get's readfile() with an appended suffix, it's better to pregmatch test it really...

ZanderBrown commented 8 years ago

maybe make that comment on the PR? #65 i assume?

roojs commented 8 years ago

Good point...

benwaffle commented 8 years ago

Hmm...can't reproduce on local build It's fixed in git, but not on valadoc.org

benwaffle commented 7 years ago

Fixed in https://github.com/valadoc/valadoc-org and http://valadoc.ogr