From 710c5e98b270e3794cc757861cde84a824bf6029 Mon Sep 17 00:00:00 2001 From: Evan Winslow Date: Wed, 19 Aug 2015 09:07:33 +0000 Subject: [PATCH 1/2] feature(discussions): More compact listing of lastest discussions Removes several features to make the listing cleaner/more compact: * All the actions/controls (like, mark-as-spam, remove-ad, etc.) * The preview text (people need to write better titles anyways) * Which group it was posted in (usually don't care) Refs #18 --- start.php | 7 + views/default/resources/discussion/index.css | 64 +++++++++ views/default/resources/discussion/index.php | 134 +++++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 views/default/resources/discussion/index.css create mode 100644 views/default/resources/discussion/index.php diff --git a/start.php b/start.php index 5f45731..674082e 100644 --- a/start.php +++ b/start.php @@ -192,4 +192,11 @@ function community_theme_pagesetup() { $actions = __DIR__ . "/actions"; elgg_register_action('admin/flush_apc', "$actions/admin/flush_apc.php", 'admin'); + + elgg_register_plugin_hook_handler('route', 'discussion', function($hook, $type, $result, $params) { + if (!isset($params['segments'][0])) { + echo elgg_view_resource('discussion/index'); + return false; + } + }); }); diff --git a/views/default/resources/discussion/index.css b/views/default/resources/discussion/index.css new file mode 100644 index 0000000..62ffe01 --- /dev/null +++ b/views/default/resources/discussion/index.css @@ -0,0 +1,64 @@ +.actions { + align-items: center; + display: flex; + flex-direction: row; + white-space: nowrap; +} + +.header { + display: flex; + flex-direction: row; + padding: 0 12px; +} + +.listItem { + align-items: center; + display: flex; + flex-direction: row; + padding-left: 12px; +} + +.listItem:not(:last-child) { + border-bottom: 1px solid #ccc; +} + +.listItem--unread { + font-weight: bold; +} + +.listItem-author { + display: block; + + /* If we don't set this explicit, the div grows to be 46px???? */ + height: 40px; +} + +.listItem-body { + flex: 100%; + +} + +.listItem-metadata { + padding: 0 12px 8px; +} + +.listItem-title { + display: block; + font-size: larger; + padding: 8px 12px; +} + +.pagination { + display: flex; + padding: 8px 12px; +} + +.pagination > * { + flex: 1; + text-align: center; +} + +.title { + flex: 100%; + padding: .5em 0; +} diff --git a/views/default/resources/discussion/index.php b/views/default/resources/discussion/index.php new file mode 100644 index 0000000..6a23bbc --- /dev/null +++ b/views/default/resources/discussion/index.php @@ -0,0 +1,134 @@ + 'object', + 'subtype' => 'discussion', + 'order_by' => 'e.last_action desc', + 'limit' => $limit, + 'offset' => $offset, + 'preload_owners' => true, + 'preload_containers' => true, +]); + +$discussions = (object)[ + 'length' => elgg_get_entities([ + 'type' => 'object', + 'subtype' => 'discussion', + 'count' => true, + ]), + 'fields' => (object)[ + 'title' => (object)['label' => 'Title'], + 'replies_length' => (object)['label' => 'Replies'], + 'last_action' => (object)['label' => 'Last activity'], + ], + 'recently_active' => (object)[ + 'label' => 'Latest discussion', + 'next' => (object)['label' => 'Older »'], + 'prev' => (object)['label' => '« Newer'], + 'actions' => [ + (object)[ + 'label' => 'Start new discussion', + 'href' => elgg_get_site_url() . 'discussion/new', + ], + ], + 'items' => array_map(function($discussion) { + $owner = $discussion->getOwnerEntity(); + + return (object)[ + 'author' => (object)[ + 'name' => $owner->name, + 'url' => $owner->getUrl(), + 'avatar' => (object)[ + 'preview' => (new ElggUser())->getIconUrl('small'), + '40x40' => $owner->getIconUrl('small'), + '100x100' => $owner->getIconUrl('medium'), + ], + ], + 'is_unread' => false, + 'last_action' => $discussion->last_action, + 'title' => $discussion->title, + 'url' => $discussion->getUrl(), + 'replies_length' => elgg_get_entities(array( + 'type' => 'object', + 'subtype' => 'discussion_reply', + 'container_guid' => $discussion->getGUID(), + 'count' => true, + 'distinct' => false, + )), + ]; + }, $recentlyActive), + ], +]; + + +elgg_register_css('resources/discussion/index', elgg_get_simplecache_url('resources/discussion/index.css')); +elgg_load_css('resources/discussion/index'); +?> + + +
+
+

+ recently_active->label; ?> +

+ +
+
    + recently_active->items as $discussion): ?> +
  1. +
    + author->avatar; ?> + <?=$discussion->author->name?> +
    +
    + + title;?> + + +
    +
  2. + +
+ +
+ + + Date: Wed, 19 Aug 2015 23:37:56 +0000 Subject: [PATCH 2/2] chore(css): Add a simple script for auto-cleaning CSS as needed --- .gitignore | 1 + README.md | 16 +++++- composer.json | 4 ++ fix.sh | 6 +++ package.json | 6 +++ views/default/resources/discussion/index.css | 55 +++++++++++++++++--- 6 files changed, 78 insertions(+), 10 deletions(-) create mode 100755 fix.sh create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 3bdeaed..05bbd28 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ download credentials.php /google2* /google8* +npm-debug.log diff --git a/README.md b/README.md index 252b3c2..b25438f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -Features -======== +# https://elgg.org + +This is the source code for the elgg.org homepage and community site. + +## Features * Turns a message board widget into a send a private message widget. Spammers were leaving messages on their message boards and we would rather have @@ -8,3 +11,12 @@ Features * Delete private messages sent from deleted users * Add APC cache flush button to admin control panel widget * Filter out friending and new bookmarks from the river + + +## Contributing + +Automatically fix various style/coding issues in changed files: + +``` +composer fix +``` diff --git a/composer.json b/composer.json index fe1726d..03aa1bd 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,10 @@ "scripts": { "post-install-cmd": "\\Elgg\\Composer\\PostUpdate::execute", "post-update-cmd": "\\Elgg\\Composer\\PostUpdate::execute", + "fix": [ + "npm install", + "./fix.sh" + ], "test": "phpunit tests", "translations:update": "tx pull -a --mode=reviewed --minimum-perc=100" }, diff --git a/fix.sh b/fix.sh new file mode 100755 index 0000000..0eb975d --- /dev/null +++ b/fix.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for line in $(git diff --name-only | grep '.*.css'); do + echo "node_modules/.bin/postcss --use autoprefixer -o $line $line" + node_modules/.bin/postcss --use autoprefixer -o $line $line +done \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..cd32757 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "autoprefixer": "^5.2.0", + "postcss-cli": "^1.5.0" + } +} diff --git a/views/default/resources/discussion/index.css b/views/default/resources/discussion/index.css index 62ffe01..d5c839d 100644 --- a/views/default/resources/discussion/index.css +++ b/views/default/resources/discussion/index.css @@ -1,20 +1,47 @@ .actions { - align-items: center; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; display: flex; - flex-direction: row; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; white-space: nowrap; } .header { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; display: flex; - flex-direction: row; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; padding: 0 12px; } .listItem { - align-items: center; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; display: flex; - flex-direction: row; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; padding-left: 12px; } @@ -34,7 +61,10 @@ } .listItem-body { - flex: 100%; + -webkit-box-flex: 100%; + -webkit-flex: 100%; + -ms-flex: 100%; + flex: 100%; } @@ -49,16 +79,25 @@ } .pagination { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; display: flex; padding: 8px 12px; } .pagination > * { - flex: 1; + -webkit-box-flex: 1; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; text-align: center; } .title { - flex: 100%; + -webkit-box-flex: 100%; + -webkit-flex: 100%; + -ms-flex: 100%; + flex: 100%; padding: .5em 0; }