Skip to content
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

URL rewriting #111

Open
jimblue opened this issue Apr 15, 2016 · 2 comments
Open

URL rewriting #111

jimblue opened this issue Apr 15, 2016 · 2 comments
Milestone

Comments

@jimblue
Copy link

jimblue commented Apr 15, 2016

Hello,

For best SEO and beautiful link I made some url rewriting with .htaccess and it's working perfectly when manually writing the modify URL in the address bar.

Now I need to modify the MinigalNano main code to generate folders links with the modified links structure. I really try a lot for one week now, and I can't found the solution but impossible to found the solution. Can Someone help me?

here are the link structure of MinigalNano :
http://localhost:8888/photos.php?dir=land%2Fabstract%2Ftest

what I want :
http://localhost:8888/photos/land/abstract/test/

the URL rewriting rules (working) :

# REWRITE PHOTOS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photos/(.*)/$ /photos.php?dir=$1 [L]
RewriteRule ^photos/(.*)/(.*)/(.*)/$ /photos.php?dir=$1%2F$1%2F$3 [L]

the PHP code of Minigal that generate folder link to modify :

//-----------------------
// READ FILES AND FOLDERS
//-----------------------

$files = array();
$dirs = array();
$img_captions = array();
if (is_dir($currentdir) && $handle = opendir($currentdir)) {
    // LOAD CAPTIONS
    while (false !== ($file = readdir($handle))) {
        // LOAD FOLDERS
        if (is_dir($currentdir . "/" . $file)) {
            if ($file != "." && $file != "..") {
                // FIRST IMAGE BG
                unset($firstimage);
                $firstimage = getfirstImage("$currentdir/" . $file);
                $linkParams = http_build_query(
                    array('dir' => ltrim("$requestedDir/$file", '/')),
                    '',
                    '&'
                );
                $linkUrl = "$autogal_page_name?$linkParams";

                $imgParams = http_build_query(
                    array(
                        'filename' => "$thumbdir/$file/$firstimage",
                        'size' => $thumb_size),
                    '',
                    '&'
                );
                $imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";

                $dirs[] = array(
                    "name" => $file,
                    "date" => filemtime($currentdir . "/" . $file),
                    "html" => "<div class=\"thumbs\"><a href=\"{$linkUrl}\"><div class=\"caption\"><div class=\"flowtype_gallery\"><h1>" . $file . "</h1></div><div class=\"caption_overlay\"></div></div><img src=\"{$imgUrl}\"  alt='$label_loading' /></a></div>",
                );
            }
        }

        // LOAD FILES
        if ($file != "." && $file != "..") {
            if (preg_match("/.jpg$/i", $file)) {
                //Read EXIF
                $exifReaden = readEXIF($currentdir . "/" . $file);
                $img_captions[$file] = $file . $exifReaden;
                //Link
                $linkUrl = str_replace('%2F', '/', rawurlencode("$currentdir/$file"));
                $imgParams = http_build_query(
                    array(
                        'filename' => "$thumbdir/$file",
                        'size' => $thumb_size),
                    '',
                    '&amp;'
                );
                $imgUrl = GALLERY_ROOT . "createthumb.php?$imgParams";
                $files[] = array(
                    "name" => $file,
                    "date" => filemtime($currentdir . "/" . $file),
                    "size" => filesize($currentdir . "/" . $file),
                    "html" => "<div class=\"thumbs\"><a href=\"{$linkUrl}\"><div class=\"caption\"><div class=\"flowtype_gallery\"><h1><i class=\"ion-ios-plus-empty\"></i></h1></div><div class=\"caption_overlay\"></div></div><img class=\"lazyload\" src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data-src=\"$imgUrl\" alt=\"$label_loading\" title=\"" . htmlentities($img_captions[$file]) . "\" /></a></div>");
            }
        }
    }
    closedir($handle);
} else {
    die("ERROR: Could not open " . htmlspecialchars(stripslashes($currentdir)) . " for reading!");
}

Thank you so much

Jim

@tmos
Copy link
Collaborator

tmos commented Apr 18, 2016

Yep, could be very nice to have in miniGal, thanks for the url rewriting stuff !
We should set a condition : if modrewrite is activated, before modifying the links I guess.

@tmos tmos mentioned this issue Jul 4, 2016
14 tasks
@tmos tmos modified the milestone: 1.0 Jul 5, 2016
@tmos
Copy link
Collaborator

tmos commented Jul 5, 2016

Will be implemented after the refactor as an option :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants