Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
Like Tree4Likes

Thread: Future Expires help

  1. #11
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    712

    Default 27 Feb 2012 @ 15.01

    quote
    So adding a dot makes it possible to modify the url, sort of?
    Er...I'm not sure what you mean there.

    It's just a way of keeping things organised. There are some small technical differences between subdomains and simple folders -- such as how cookies can be set, and whether you get another DNS lookup -- but basically you're just using them for convenience.

    In particular, a subdomain is cheaper than running a completely separate domain (which would incur a registrar fee).

    The "multisite" setup is especially "tidy", because you can keep all the settings separate. It's like having a separate account.
      Reply With Quote

  2. #12
    Member Jacob's Avatar
    Join Date
    Feb 2009
    Posts
    248

    Default 29 Feb 2012 @ 21.02

    What about site navigation, how do you avoid having to rename the links?
      Reply With Quote

  3. #13
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    712

    Default 1 Mar 2012 @ 09.10

    quote
    What about site navigation, how do you avoid having to rename the links?
    Originally Posted by Jacob View Post
    Wherever practical, make all your links relative. For example:

    • Good: "/articles/jam/raspberry"
    • Bad: "dev.domain.com/articles/jam/raspberry"

    (If you're seriously into performance, you can even insert links using a function that automatically creates the shortest possible URL!)

    This works well within your HTML code, but sometimes in your application code (e.g. PHP) you might need full URLs. You can construct these with a PHP function.

    For example, on my site, a full URL in PHP could be set like this:

    Code:
    $URL = $site->domain() . "/articles/jam/raspberry";
    $site is an object that I've already instantiated. It's domain() method returns the domain part of the URL (e.g. "http://www.domain.com/"). I can supply complete code if you like.
    Last edited by Mike Hopley; 1 Mar 2012 at @ 09.43.
      Reply With Quote

  4. #14
    Member Jacob's Avatar
    Join Date
    Feb 2009
    Posts
    248

    Default 1 Mar 2012 @ 21.50

    quote
    (If you're seriously into performance, you can even insert links using a function that automatically creates the shortest possible URL!)
    How many kilobits do you think you have saved?

    quote
    /articles/jam/raspberry
    That is what I thought, then you could browse your site as if it were live yeah?

    How do you set up your localhost enviroment, do you use Wamp?

    quote
    I can supply complete code if you like.
    Yeah I would be interested to see how it works and if I could apply myself

    Thanks
      Reply With Quote

  5. #15
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    712

    Default 2 Mar 2012 @ 09.29

    quote
    How many kilobits do you think you have saved?
    Originally Posted by Jacob View Post
    Not many. It's the sort of thing that Yahoo would do. It would mainly be useful on pages with long lists of links.


    quote
    That is what I thought, then you could browse your site as if it were live yeah?
    Yes, exactly.


    quote
    How do you set up your localhost enviroment, do you use Wamp?
    Yes. I have four copies of my site:
    • Localhost, for whatever I'm currently working on.
    • A development site on the server.
    • A staging site on the server (I don't use this much).
    • The live site.

    I use Mercurial, a version control system, to manage the files. In practice, I almost always treat Localhost as the "central" repository, and push changes out to the remote repositories on dev, stage, or live.

    quote
    Yeah I would be interested to see how it works and if I could apply myself

    Thanks
    Bear in mind this is just what works for me. I imagine there are better implementations from, say, a PHP framework like CakePHP.

    I've redacted some directory names.

    Code:
    class Site {    // Resolves between dev, stage, and live sites
    
        function branch() {
            switch (htmlentities(dirname(__FILE__), ENT_QUOTES)) {
                case "/home/live_user/public_html":
                $branch = "live";
                break;
    
                case "/home/stage_user/public_html":
                $branch = "stage";
                break;
    
                case "/home/dev_user/public_html":
                $branch = "dev";
                break;
    
                case "C:\\local\\path_to_website\\public_html":
                $branch = "local";
                break;
    
                default:
                die();
            }
            return $branch;
        }
    
    
        function domain() {
            switch ($this->branch()) {
                case "dev": case "stage":
                $root = "http://www.".$this->branch().".badmintonbible.com/";
                break;
    
                case "live":
                $root = "http://www.badmintonbible.com/";
                break;
    
                case "local":
                $root = "http://localhost/";
                break;
    
                default:
                die();
            }
            return $root;
        }
    
        function web_root() {
            switch ($this->branch()) {
                case "dev":
                $root = "/home/dev_user/public_html/";
                break;
    
                case "stage":
                $root = "/home/stage_user/public_html/";
                break;
    
                case "live":
                $root = "/home/live_user/public_html/";
                break;
    
                case "local":
                $root = "C:\\local\\path_to_website\\public_html"";
                break;
    
                default:
                die();
            }
            return $root;
        }
    
        function bin_root() {
            switch ($this->branch()) {
                case "local":
                $root = "C:\\local\\path_to_website\\bin_directory"";
                break;
    
                case "dev":
                $root = "/home/dev_user/bin_directory/";
                break;
    
                case "stage":
                $root = "/home/stage_user/bin_directory/";
                break;
    
                case "live":
                $root = "/home/live_user/bin_directory/";
                break;
    
                default:
                die();
            }
            return $root;
        }
    
        function current_page() {
            $path = htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES);
            return $path;
        }
    
        function current_page_full() {
            $host = htmlentities($_SERVER['HTTP_HOST']);
            $path = "http://".$host.$this->current_page();
            return $path;
        }
    }
    
    $site = new Site();
    Last edited by Mike Hopley; 2 Mar 2012 at @ 09.34.
      Reply With Quote

  6. #16
    Member Jacob's Avatar
    Join Date
    Feb 2009
    Posts
    248

    Default 23 Mar 2012 @ 20.02

    Back tracking here:

    quote
    The development and staging sites should probably be password-protected.
    Why is this?

    Thanks
      Reply With Quote

  7. #17
    Trusted Guru Frinkky's Avatar
    Join Date
    Dec 2008
    Posts
    1,678
    Blog Entries
    1

    Default 24 Mar 2012 @ 09.29

    You don't particularly want visitors and search engines discovering your development environment. It's possible that security won't be as thorough amongst other things.
      Reply With Quote

  8. #18
    Member janvt's Avatar
    Join Date
    Jan 2011
    Posts
    182

    Default 26 Mar 2012 @ 08.39

    quote
    Bear in mind this is just what works for me. I imagine there are better implementations from, say, a PHP framework like CakePHP.
    Originally Posted by Mike Hopley View Post
    This is the perfect place for an abstract factory pattern implementation Bit complexer, but a handy design pattern to know and a lovely place to practice.
      Reply With Quote

  9. #19
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    712

    Default 26 Mar 2012 @ 12.44

    quote
    This is the perfect place for an abstract factory pattern implementation Bit complexer, but a handy design pattern to know and a lovely place to practice.
    Originally Posted by janvt View Post
    Sounds interesting.

    What benefit would the abstract factory pattern give, compared to my naive code?
      Reply With Quote

  10. #20
    Member janvt's Avatar
    Join Date
    Jan 2011
    Posts
    182

    Default 26 Mar 2012 @ 14.39

    In this case: none, seeing as you'd end up with more code than you have now. Was just pointing out that this a text book example. Actually you're almost using a factory implemetation, you're just using switch blocks in the class that defines your interface instead of implementing the logic in child classes. The factory pattern would start making sense if you had, say, differences in the implementation of the "current_page" function.
      Reply With Quote

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •