├── .gitignore ├── info.php ├── img ├── icon-wp.png └── icon-gear.png ├── README.md ├── config.sample.php ├── css └── main.css └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | config.php -------------------------------------------------------------------------------- /info.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /img/icon-wp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmall/LocalHomePage/HEAD/img/icon-wp.png -------------------------------------------------------------------------------- /img/icon-gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmall/LocalHomePage/HEAD/img/icon-gear.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### A Local Home Page for OSX Web Development 2 | 3 | This is a small and simple local home page that automatically lists, and provide links to, your local sites. It's a companion project for a [blog post](http://mallinson.ca/post/osx-web-development) I wrote about setting up your Mac for web development. 4 | 5 | 6 | * img/icon-gear.png from [Icons DB](http://www.iconsdb.com/black-icons/gear-2-icon.html) -------------------------------------------------------------------------------- /config.sample.php: -------------------------------------------------------------------------------- 1 | 'Tool', 'url' => 'http://example.com/' ), 39 | array( 'name' => 'Web Host Admin', 'url' => 'http://example.com/' ), 40 | array( 'name' => 'Github', 'url' => 'http://github.com/' ), 41 | ); 42 | 43 | /* 44 | * 45 | * Options for sites being displayed. These are completely optional, if you don't set 46 | * anything there are default options which will take over. 47 | * 48 | * If you only want to specify a display name for a site you can use the format: 49 | * 50 | * 'sitedir' => 'Display Name', 51 | * 52 | * Otherwise, if you want to set additional options you'll use an array for the options. 53 | * 54 | * 'sitedir' => array( 'displayname' => 'Display Name', 'adminurl' => 'http://example.sites.dev/admin' ), 55 | * 56 | */ 57 | $siteoptions = array( 58 | // 'dirname' => 'Display Name', 59 | // 'dirname' => array( 'displayname' => 'DisplayName', 'adminurl' => 'http://something/admin' ), 60 | 61 | ); 62 | 63 | /* 64 | * 65 | * Directory names of sites you want to hide from the page. If you're using multiple directories 66 | * in $dir be aware that any directory names in the array below that show up in any of 67 | * your directories will be hidden. 68 | * 69 | */ 70 | $hiddensites = array( 'home', ); -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | 6 | .canvas { 7 | width:75%; 8 | margin: 0; 9 | padding:15px 55px; 10 | background-color: #FFF; 11 | } 12 | 13 | ul { 14 | list-style: none; 15 | margin:10px 0 5px 0; 16 | padding: 0; 17 | } 18 | 19 | nav ul li { 20 | display: block; 21 | margin: 0; 22 | font-size: .8em; 23 | } 24 | 25 | 26 | li { 27 | font-size: 1rem; 28 | line-height: 1.8rem; 29 | font-family: helvetica, arial, sans-serif; 30 | } 31 | 32 | li a { 33 | text-decoration: none; 34 | color: #444; 35 | } 36 | 37 | .sites li { 38 | width: 100%; 39 | height: 2rem; 40 | position: relative; 41 | background-color: #F4F4F4; 42 | margin: 2px 0 2px 0; 43 | padding: 0; 44 | float: left; 45 | } 46 | 47 | .sites li:hover { 48 | background-color: #EEE; 49 | } 50 | 51 | 52 | .icon, .sites img { 53 | float: right; 54 | font-size: .7rem; 55 | display: inline-block; 56 | text-indent: -10000px; 57 | background-size: 1.2rem; 58 | background-repeat: no-repeat; 59 | background-position: center center; 60 | height: 2rem; 61 | width: 2rem; 62 | } 63 | 64 | .sites img, .sites .no-img { 65 | float: left; 66 | height: 2rem; 67 | width: 2rem; 68 | background-color: #EEE; 69 | } 70 | 71 | .sites .no-img { 72 | background-color: #999; 73 | } 74 | 75 | 76 | .wp { 77 | background-color: #21759a; 78 | background-image: url('/img/icon-wp.png'); 79 | } 80 | 81 | .site { 82 | padding: 0 10px; 83 | } 84 | 85 | .cf:before, 86 | .cf:after { 87 | content: " "; /* 1 */ 88 | display: table; /* 2 */ 89 | } 90 | 91 | .cf:after { 92 | clear: both; 93 | } 94 | 95 | 96 | 97 | 98 | @media all and (min-width: 699px) { 99 | 100 | body { 101 | background-color: #DDD; 102 | } 103 | 104 | .canvas { 105 | width:80%; 106 | margin: 20px auto; 107 | box-shadow: 0 0 20px #AAA; 108 | } 109 | 110 | .sites li { 111 | width: 45%; 112 | height: 2rem; 113 | position: relative; 114 | background-color: #F4F4F4; 115 | margin: 2px 3% 2px 0; 116 | padding: 0; 117 | float: left; 118 | } 119 | 120 | nav ul li { 121 | display: inline; 122 | margin: 5px 5px 5px 0; 123 | padding: 4px 12px; 124 | background-color: #EEE; 125 | border-radius: 2px; 126 | } 127 | 128 | 129 | 130 | } 131 | 132 | .admin { 133 | background-color: #000000; 134 | background-image: url('/img/icon-gear.png'); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Local 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |
19 | 20 |

My Local Sites

21 | 22 | 31 | 32 |
33 | 34 | 35 | ', $dirname ); 41 | 42 | foreach( glob( $d ) as $file ) { 43 | 44 | $project = basename($file); 45 | 46 | if ( in_array( $project, $hiddensites ) ) continue; 47 | 48 | echo '
  • '; 49 | 50 | $siteroot = sprintf( 'http://%1$s.%2$s.%3$s', $project, $dirname, $tld ); 51 | 52 | // Display an icon for the site 53 | $icon_output = ''; 54 | foreach( $icons as $icon ) { 55 | 56 | if ( file_exists( $file . '/' . $icon ) ) { 57 | $icon_output = sprintf( '', $siteroot, $icon ); 58 | break; 59 | } // if ( file_exists( $file . '/' . $icon ) ) 60 | 61 | } // foreach( $icons as $icon ) 62 | echo $icon_output; 63 | 64 | // Display a link to the site 65 | $displayname = $project; 66 | if ( array_key_exists( $project, $siteoptions ) ) { 67 | if ( is_array( $siteoptions[$project] ) ) 68 | $displayname = array_key_exists( 'displayname', $siteoptions[$project] ) ? $siteoptions[$project]['displayname'] : $project; 69 | else 70 | $displayname = $siteoptions[$project]; 71 | } 72 | printf( '%2$s', $siteroot, $displayname ); 73 | 74 | 75 | // Display an icon with a link to the admin area 76 | $adminurl = ''; 77 | // We'll start by checking if the site looks like it's a WordPress site 78 | if ( is_dir( $file . '/wp-admin' ) ) 79 | $adminurl = sprintf( 'http://%1$s/wp-admin', $siteroot ); 80 | 81 | // If the user has defined an adminurl for the project we'll use that instead 82 | if (isset($siteoptions[$project]) && is_array( $siteoptions[$project] ) && array_key_exists( 'adminurl', $siteoptions[$project] ) ) 83 | $adminurl = $siteoptions[$project]['adminurl']; 84 | 85 | // If there's an admin url then we'll show it - the icon will depend on whether it looks like WP or not 86 | if ( ! empty( $adminurl ) ) 87 | printf( 'Admin', $adminurl, is_dir( $file . '/wp-admin' ) ? 'wp' : 'admin' ); 88 | 89 | 90 | echo '
  • '; 91 | 92 | } // foreach( glob( $d ) as $file ) 93 | 94 | echo ''; 95 | 96 | } // foreach ( $dir as $d ) 97 | ?> 98 |
    99 | 100 | 101 | 102 | 105 | 106 |
    107 | 108 | 109 | --------------------------------------------------------------------------------