diff --git a/assets/fonts/Lato-Black.ttf b/assets/fonts/Lato-Black.ttf new file mode 100644 index 00000000..6848db0d Binary files /dev/null and b/assets/fonts/Lato-Black.ttf differ diff --git a/assets/fonts/Lato-BlackItalic.ttf b/assets/fonts/Lato-BlackItalic.ttf new file mode 100644 index 00000000..5decf129 Binary files /dev/null and b/assets/fonts/Lato-BlackItalic.ttf differ diff --git a/assets/fonts/Lato-Bold.ttf b/assets/fonts/Lato-Bold.ttf new file mode 100644 index 00000000..74343694 Binary files /dev/null and b/assets/fonts/Lato-Bold.ttf differ diff --git a/assets/fonts/Lato-BoldItalic.ttf b/assets/fonts/Lato-BoldItalic.ttf new file mode 100644 index 00000000..684aacf5 Binary files /dev/null and b/assets/fonts/Lato-BoldItalic.ttf differ diff --git a/assets/fonts/Lato-Hairline.ttf b/assets/fonts/Lato-Hairline.ttf new file mode 100644 index 00000000..288be295 Binary files /dev/null and b/assets/fonts/Lato-Hairline.ttf differ diff --git a/assets/fonts/Lato-HairlineItalic.ttf b/assets/fonts/Lato-HairlineItalic.ttf new file mode 100644 index 00000000..c2bfd335 Binary files /dev/null and b/assets/fonts/Lato-HairlineItalic.ttf differ diff --git a/assets/fonts/Lato-Heavy.ttf b/assets/fonts/Lato-Heavy.ttf new file mode 100644 index 00000000..a394d613 Binary files /dev/null and b/assets/fonts/Lato-Heavy.ttf differ diff --git a/assets/fonts/Lato-HeavyItalic.ttf b/assets/fonts/Lato-HeavyItalic.ttf new file mode 100644 index 00000000..0d7fe624 Binary files /dev/null and b/assets/fonts/Lato-HeavyItalic.ttf differ diff --git a/assets/fonts/Lato-Italic.ttf b/assets/fonts/Lato-Italic.ttf new file mode 100644 index 00000000..3d3b7a29 Binary files /dev/null and b/assets/fonts/Lato-Italic.ttf differ diff --git a/assets/fonts/Lato-Light.ttf b/assets/fonts/Lato-Light.ttf new file mode 100644 index 00000000..a958067a Binary files /dev/null and b/assets/fonts/Lato-Light.ttf differ diff --git a/assets/fonts/Lato-LightItalic.ttf b/assets/fonts/Lato-LightItalic.ttf new file mode 100644 index 00000000..5e45ad9a Binary files /dev/null and b/assets/fonts/Lato-LightItalic.ttf differ diff --git a/assets/fonts/Lato-Medium.ttf b/assets/fonts/Lato-Medium.ttf new file mode 100644 index 00000000..34f1ff5d Binary files /dev/null and b/assets/fonts/Lato-Medium.ttf differ diff --git a/assets/fonts/Lato-MediumItalic.ttf b/assets/fonts/Lato-MediumItalic.ttf new file mode 100644 index 00000000..b2fa3963 Binary files /dev/null and b/assets/fonts/Lato-MediumItalic.ttf differ diff --git a/assets/fonts/Lato-Regular.ttf b/assets/fonts/Lato-Regular.ttf new file mode 100644 index 00000000..04ea8efb Binary files /dev/null and b/assets/fonts/Lato-Regular.ttf differ diff --git a/assets/fonts/Lato-Semibold.ttf b/assets/fonts/Lato-Semibold.ttf new file mode 100644 index 00000000..d58edee7 Binary files /dev/null and b/assets/fonts/Lato-Semibold.ttf differ diff --git a/assets/fonts/Lato-SemiboldItalic.ttf b/assets/fonts/Lato-SemiboldItalic.ttf new file mode 100644 index 00000000..cc825312 Binary files /dev/null and b/assets/fonts/Lato-SemiboldItalic.ttf differ diff --git a/assets/fonts/Lato-Thin.ttf b/assets/fonts/Lato-Thin.ttf new file mode 100644 index 00000000..24aaaba8 Binary files /dev/null and b/assets/fonts/Lato-Thin.ttf differ diff --git a/assets/fonts/Lato-ThinItalic.ttf b/assets/fonts/Lato-ThinItalic.ttf new file mode 100644 index 00000000..140969da Binary files /dev/null and b/assets/fonts/Lato-ThinItalic.ttf differ diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 00000000..bbcc8252 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,220 @@ +@font-face { + font-family: "LatoHairline"; + src: url("fonts/Lato-Hairline.ttf") format("truetype"); +} + +@font-face { + font-family: "LatoLight"; + src: url("fonts/Lato-Light.ttf") format("truetype"); +} + +*{ + box-sizing:border-box; +} + +html,body{ + margin:0; + padding:0; +} + +html{ + font-family:'LatoLight', 'Lato', sans-serif; + font-weight:300; + font-size:100%; +} + +a{ + text-decoration:none; + color:inherit; +} + +#top-bar{ + background:#f5f5f5; + padding:8px 14px; + height:55px; + text-align:center; + position:relative; + font-weight:300; +} + +#top-bar .header{ + position:absolute; + top:14px; + left:14px; + display:inline-block; + font-size:16px; + font-weight:300; + line-height:0.9em; + background:url('/images/friendica.svg') top left no-repeat; + background-size:14px; + padding-left:18px; + margin:0; +} + +#top-bar .search-form{ + margin:0 20px; + display:inline-block; +} +#top-bar .search-wrapper{ + background:#fff; +} + +nav#links{ + position:absolute; + top:0; + right:14px; + line-height:55px; +} +nav#links a{ + display:inline-block; + margin:0 4px; + padding:0 5px; +} + +.sub-menu-outer{ + background:#eee; + line-height:45px; + height:45px; + border-top:1px solid #ddd; + border-bottom:1px solid #ddd; +} +.sub-menu-outer .sub-menu-inner{ + width:500px; + margin:auto; +} +.sub-menu-inner .option{ + padding:9px 6px; + margin:0 5px; +} +.sub-menu-inner .option.active{ + border-bottom:2px solid #f00; +} + +.search-results, +.homepage-wrapper{ + width:500px; + margin:auto; + text-align:center; +} + +.search-results{ + margin-bottom:25px; +} + +.homepage-wrapper{ + margin:120px auto; +} + +.homepage-wrapper .header{ + font-size:68px; + font-family:'LatoHairline', 'Lato', sans-serif; + font-weight:100; + line-height:0.9em; + background:url('/images/friendica.svg') top left no-repeat; + background-size:61px; + margin-left:40px; +} +.homepage-wrapper .about{ + text-align:justify; + line-height:1.5em; + color:#555; +} + +.homepage-wrapper .profiles{ + margin-top:3em; +} + +.profile{ + display:table; + width:100%; + text-decoration:none; + color:#000; + padding:2px; + outline:none; +} + +.profile.selected, +.profile:focus, +.profile:hover{ + padding:1px; + border:1px solid #ccc; +} + +.profile .profile-photo, +.profile .profile-info{ + display:table-cell; + vertical-align:top; + text-align:left; +} + +.profile .profile-photo{ + margin:8px; + border-radius:15px; + border:1px solid #ddd; +} +.profile .profile-info{ + padding:8px; + width:100%; +} +.profile .profile-info strong{ + font-weight:600; +} +.profile .profile-info .fa{ + line-height:1.1em; + color:#999; +} +.profile .profile-info .url{ + font-size:80%; + margin-bottom:3px; + color:#555; +} + +.search-wrapper{ + position:relative; + display:inline-block; + width:500px; + background:#f5f5f5; + border:1px solid #ddd; + border-radius:8px; + height:38px; + line-height:22px; +} + .search-wrapper .search-field{ + line-height:22px; + display:block; + border:none; + outline:none; + background:none; + padding:8px 12px; + padding-right:117px; + width:100%; + } + .search-wrapper .reset{ + position:absolute; + top:0; + right:65px; + height:25px; + width:25px; + margin:6px; + padding:0; + line-height:1; + font-size:12px; + color:#555; + background:#eee; + border:1px solid #ddd; + border-radius:20px; + font-family:'FontAwesome'; + font-weight:100; + } + .search-wrapper .search{ + border:none; + border-left:1px solid #ddd; + color:#555; + background:#eee; + position:absolute; + top:0; + right:0; + height:36px; + width:65px; + border-radius:0 8px 8px 0; + } diff --git a/images/friendica.svg b/images/friendica.svg new file mode 100644 index 00000000..b001c0e0 --- /dev/null +++ b/images/friendica.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/mod/home.php b/mod/home.php index 3c437657..28c9432c 100755 --- a/mod/home.php +++ b/mod/home.php @@ -1,14 +1,17 @@ get_baseurl() . "/profile/" . $r[0]['nickname'] ); - else - goaway( $a->get_baseurl() . "/register" ); +use Friendica\Directory\Rendering\View; +use Friendica\Directory\Helper\Profile as ProfileHelper; +if(! function_exists('home_content')) { +function home_content(&$a) { + + $profiles = q("SELECT * FROM profile WHERE comm=1 AND LENGTH(pdesc)>0 ORDER BY RAND() LIMIT 3"); + + $view = new View('homepage', 'minimal'); + $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); + $view->output(array( + 'profiles' => $profiles + )); + }} - - diff --git a/mod/photo.php b/mod/photo.php index 31d8c6cc..cc542bee 100755 --- a/mod/photo.php +++ b/mod/photo.php @@ -1,8 +1,11 @@ argc) { case 2: $photo = $a->argv[1]; @@ -23,9 +26,27 @@ function photo_init(&$a) { if(x($data) === false || (! strlen($data))) { $data = file_get_contents('images/default-profile-sm.jpg'); } - - header("Content-type: image/jpeg"); + + //Enable async process from here. + session_write_close(); + + //Try and cache our result. + $etag = md5($data); + header('Etag: '.$etag); header('Expires: ' . datetime_convert('UTC','UTC', 'now + 1 week', 'D, d M Y H:i:s' . ' GMT')); + header("Cache-Control: max-age=".intval(7*24*3600)); + if(function_exists('header_remove')) { + header_remove('Pragma'); + header_remove('pragma'); + } + + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { + header('HTTP/1.1 304 Not Modified'); + exit; + } + + header("Content-type: image/jpeg"); echo $data; exit; + } \ No newline at end of file diff --git a/mod/search.php b/mod/search.php new file mode 100644 index 00000000..7011f569 --- /dev/null +++ b/mod/search.php @@ -0,0 +1,93 @@ +argc >= 2){ + + $filter = $a->argv[1]; + switch($filter){ + + case 'forums': + $community = 1; + break; + + case 'people': + $community = 0; + break; + + default: + $community = null; + $filter = null; + break; + + } + + } + + $alpha = false; + if(x($_GET, 'alpha') == 1) + $alpha = true; + + //Query + $search = ((x($_GET,'query')) ? notags(trim($_GET['query'])) : ''); + + if(empty($search)){ + goaway('/home'); + } + + if($search) + $alpha = true; + + //Run our query. + if($search) + $search = dbesc($search . '*'); + $sql_extra = ((strlen($search)) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `gender`, `marital`, `tags` ) + AGAINST ('$search' IN BOOLEAN MODE) " : ""); + + if(!is_null($community)) + $sql_extra .= " and comm=".intval($community)." "; + + $sql_extra = str_replace('%','%%',$sql_extra); + + $total = 0; + $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra "); + if(count($r)){ + $total = $r[0]['total']; + $a->set_pager_total($r[0]['total']); + } + + if($alpha) + $order = " order by name asc "; + else + $order = " order by updated desc, id desc "; + + + $r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ", + intval($a->pager['start']), + intval($a->pager['itemspage']) + ); + + //Show results. + $view = new View('search'); + + $view->addHelper('paginate', function()use($a){return paginate($a);}); + $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); + $view->addHelper('filterAllUrl', SearchHelper::get('filterAllUrl')); + $view->addHelper('filterPeopleUrl', SearchHelper::get('filterPeopleUrl')); + $view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl')); + + $view->output(array( + 'total' => number_format($total), + 'results' => $r, + 'filter' => $filter, + 'query' => x($_GET,'query') ? $_GET['query'] : '' + )); + +} \ No newline at end of file diff --git a/src/Helper/BaseHelper.php b/src/Helper/BaseHelper.php new file mode 100644 index 00000000..a6661f2b --- /dev/null +++ b/src/Helper/BaseHelper.php @@ -0,0 +1,47 @@ +{$name}; + } + + /** + * A reference to the global App. + * @var \App + */ + protected $app; + + public function __construct() + { + global $a; + $this->app = $a; + } + + //Provides access to a wrapper for your helper functions. + public function __get($name) + { + + if(!method_exists($this, $name)){ + throw new OutOfBoundsException("Helper method '$name' does not exist on ".get_class($this)); + } + + $helper = $this; + $method = new ReflectionMethod($this, $name); + return function()use($method, $helper){ + $arguments = func_get_args(); + return $method->invokeArgs($helper, $arguments); + }; + + } + +} \ No newline at end of file diff --git a/src/Helper/Profile.php b/src/Helper/Profile.php new file mode 100644 index 00000000..7fca5366 --- /dev/null +++ b/src/Helper/Profile.php @@ -0,0 +1,16 @@ +app->get_baseurl() . '/photo/' . $profileId; + } + +} \ No newline at end of file diff --git a/src/Helper/Search.php b/src/Helper/Search.php new file mode 100644 index 00000000..f33ef552 --- /dev/null +++ b/src/Helper/Search.php @@ -0,0 +1,26 @@ +app->get_baseurl() . '/search?query=' . urlencode($query); + } + + public function filterPeopleUrl($query) + { + return $this->app->get_baseurl() . '/search/people?query=' . urlencode($query); + } + + public function filterForumsUrl($query) + { + return $this->app->get_baseurl() . '/search/forums?query=' . urlencode($query); + } + +} \ No newline at end of file diff --git a/src/Rendering/View.php b/src/Rendering/View.php new file mode 100644 index 00000000..5b6d87f7 --- /dev/null +++ b/src/Rendering/View.php @@ -0,0 +1,109 @@ +helpers; + } + + public function addHelper($name, Closure $helper) + { + $this->helpers[$name] = $helper; + } + + public function getView(){ + return $this->view; + } + + public function setView($value){ + $this->view = $value; + } + + public function getLayout(){ + return $this->layout; + } + + public function setLayout($value){ + $this->layout = $value; + } + + public function __construct($view=null, $layout="default") + { + + $this->view = $view; + $this->layout = $layout; + $this->helpers = array(); + + } + + public function render(array $data=array()) + { + + //First the outer view. + $view = self::getViewPath($this->view); + $viewContent = $this->encapsulatedRequire($view, $data); + + //Then the layout, including the view as $content. + $data['content'] = $viewContent; + $layout = self::getLayoutPath($this->layout); + return $this->encapsulatedRequire($layout, $data); + + } + + public function output(array $data=array()) + { + + header("Content-type: text/html; charset=utf-8"); + echo $this->render($data); + exit; + + } + + public function encapsulatedRequire($filename, array $data=null) + { + + //This will provide our variables on the global scope. + $call = function($__FILE__, $__VARS__){ + extract($__VARS__, EXTR_SKIP); + require $__FILE__; + }; + + //Use our current data as fallback. + if(!is_array($data)){ + $data = $this->currentData; + } + + //This will add the helper class to $this. + $helpers = new ViewHelpers($this, $data); + $call = $call->bindTo($helpers, get_class($helpers)); + + //Run and return the value. + ob_start(); + $call($filename, $data); + return ob_get_clean(); + + } + +} \ No newline at end of file diff --git a/src/Rendering/ViewHelpers.php b/src/Rendering/ViewHelpers.php new file mode 100644 index 00000000..1ee0c652 --- /dev/null +++ b/src/Rendering/ViewHelpers.php @@ -0,0 +1,59 @@ +view = $view; + $this->contextData = $contextData; + } + + public function view($name, array $overrides=null) + { + + $data = $this->contextData; + + if(is_array($overrides)){ + $data = array_merge($data, $overrides); + } + + return $this->view->encapsulatedRequire(View::getViewPath($name), $data); + + } + + public function layout($name, array $overrides=null) + { + + $data = $this->contextData; + + if(is_array($overrides)){ + $data = array_merge($data, $overrides); + } + + return $this->view->encapsulatedRequire(View::getLayoutPath($name), $data); + + } + + public function __call($name, $arguments) + { + + $helpers = $this->view->getHelpers(); + + if(array_key_exists($name, $helpers)){ + return call_user_func_array($helpers[$name], $arguments); + } + + throw new BadMethodCallException("Helper method '$name' does not exist or is not added."); + + } + +} \ No newline at end of file diff --git a/src/templates/layout/_navigation.php b/src/templates/layout/_navigation.php new file mode 100644 index 00000000..e971c99a --- /dev/null +++ b/src/templates/layout/_navigation.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/src/templates/layout/_searcher.php b/src/templates/layout/_searcher.php new file mode 100644 index 00000000..90a75eea --- /dev/null +++ b/src/templates/layout/_searcher.php @@ -0,0 +1,7 @@ +
+
+ + + +
+
diff --git a/src/templates/layout/_topBar.php b/src/templates/layout/_topBar.php new file mode 100644 index 00000000..cc822ce2 --- /dev/null +++ b/src/templates/layout/_topBar.php @@ -0,0 +1,13 @@ +
+ + +

+ Friendica    
    Directory +

+
+ + layout('_searcher'); ?> + + layout('_navigation'); ?> + +
\ No newline at end of file diff --git a/src/templates/layout/default.php b/src/templates/layout/default.php new file mode 100644 index 00000000..ccac1ae3 --- /dev/null +++ b/src/templates/layout/default.php @@ -0,0 +1,5 @@ +layout('minimal', array( + 'topBar' => $this->layout('_topBar') +)); diff --git a/src/templates/layout/minimal.php b/src/templates/layout/minimal.php new file mode 100644 index 00000000..7ae05dc9 --- /dev/null +++ b/src/templates/layout/minimal.php @@ -0,0 +1,20 @@ + + + + + + + + Friendica Directory + + + + + + + + + + + + \ No newline at end of file diff --git a/src/templates/view/_profile.php b/src/templates/view/_profile.php new file mode 100644 index 00000000..fce91d10 --- /dev/null +++ b/src/templates/view/_profile.php @@ -0,0 +1,23 @@ + + + +
+ +
+
+
+ + + + + + + +
+
+ +
\ No newline at end of file diff --git a/src/templates/view/homepage.php b/src/templates/view/homepage.php new file mode 100644 index 00000000..a221a65a --- /dev/null +++ b/src/templates/view/homepage.php @@ -0,0 +1,26 @@ +layout('_navigation'); ?> + +
+ +

+ Friendica    
    Directory +

+ + layout('_searcher'); ?> + +

+ Friendica is a decentralized social network. + And this is a directory to find people on this network. + Vivamus condimentum tempor pellentesque. Phasellus turpis nulla, lacinia vitae quam in, + cursus semper est. Ut lobortis ex quis sodales porta. Nam rhoncus tortor lobortis auctor + efficitur. Ut ac ullamcorper lorem. +

+ +
+

Random groups

+ view('_profile', array('profile'=>$profile)); + ?> +
+ +
diff --git a/src/templates/view/search.php b/src/templates/view/search.php new file mode 100644 index 00000000..2d2b0fb2 --- /dev/null +++ b/src/templates/view/search.php @@ -0,0 +1,32 @@ + + +
+
+ + + +

Results for "" ()

+ view('_profile', array('profile'=>$profile)); + + echo $this->paginate(); + + ?> + + + + +

There were no results

+ + + +
+