From 0c65b2c038a309a867ef9e25108e905e127a4be3 Mon Sep 17 00:00:00 2001 From: Ryon Coleman Date: Wed, 10 Mar 2021 04:47:48 +0000 Subject: [PATCH 01/34] feat: improve course section sidebar styling and add tag browser mockup --- html-templates/sections/courseSection.tpl | 188 +++++++++++++----- site-root/sass/slate/_common.scss | 72 ++++++- site-root/sass/slate/_modules.scss | 3 +- .../sass/slate/modules/_key-value-list.scss | 13 +- site-root/sass/slate/modules/_people.scss | 40 ++-- site-root/sass/slate/modules/_tag-list.scss | 30 +++ 6 files changed, 267 insertions(+), 79 deletions(-) create mode 100644 site-root/sass/slate/modules/_tag-list.scss diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index e024da833..637afd8c0 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -95,38 +95,45 @@ -{/block} \ No newline at end of file +{/block} diff --git a/site-root/sass/slate/_common.scss b/site-root/sass/slate/_common.scss index 2324fc178..a60173a13 100644 --- a/site-root/sass/slate/_common.scss +++ b/site-root/sass/slate/_common.scss @@ -45,13 +45,33 @@ body { } } -.text-left { text-align: left !important; } -.text-right { text-align: right !important; } -.text-center { text-align: center !important; } -.text-justify { text-align: justify !important; } -.text-nowrap { white-space: nowrap !important; } -.text-nolead { margin-top: 0 !important; } -.text-notrail { margin-bottom: 0 !important; } +.text-left { + text-align: left !important; +} + +.text-right { + text-align: right !important; +} + +.text-center { + text-align: center !important; +} + +.text-justify { + text-align: justify !important; +} + +.text-nowrap { + white-space: nowrap !important; +} + +.text-nolead { + margin-top: 0 !important; +} + +.text-notrail { + margin-bottom: 0 !important; +} .sidebar-item { margin: 1em 0 3em; @@ -59,6 +79,40 @@ body { .empty-text { margin: .5em 0; } + + .sidebar-collapsible-toggle { + background-color: rgba($text-color, .05); + border-radius: .25em; + cursor: pointer; + font-size: .75em; + margin-top: 1em; + padding: .25em; + text-align: center; + text-transform: uppercase; + + &:hover, + &:focus { + background-color: rgba($text-color, .1); + } + } + + .collapsible-collapse-text { + display: none; + } + + .sidebar-collapsible[open] { + >.sidebar-collapsible-toggle { + margin-bottom: 1em; + } + + .collapsible-expand-text { + display: none; + } + + .collapsible-collapse-text { + display: unset; + } + } } .sidebar-item-title { @@ -94,7 +148,7 @@ body { width: 250px; } - > .inner { + >.inner { background-position: center; background-repeat: no-repeat; background-size: cover; @@ -111,4 +165,4 @@ body { margin: 1em 0 0; } } -} \ No newline at end of file +} diff --git a/site-root/sass/slate/_modules.scss b/site-root/sass/slate/_modules.scss index e243bb362..f0956ea03 100644 --- a/site-root/sass/slate/_modules.scss +++ b/site-root/sass/slate/_modules.scss @@ -15,5 +15,6 @@ @import 'modules/slate-menu'; @import 'modules/source-grid'; @import 'modules/splitview'; +@import 'modules/tag-list'; @import 'modules/todo'; -@import 'modules/wizards'; \ No newline at end of file +@import 'modules/wizards'; diff --git a/site-root/sass/slate/modules/_key-value-list.scss b/site-root/sass/slate/modules/_key-value-list.scss index 7391c7371..cf6b8d626 100644 --- a/site-root/sass/slate/modules/_key-value-list.scss +++ b/site-root/sass/slate/modules/_key-value-list.scss @@ -13,6 +13,7 @@ .kv-key, .kv-value { margin: 0; + padding: 0; } .kv-key { @@ -34,12 +35,16 @@ .kv-pair { display: table-row; } - + .kv-key, - .kv-value { + .kv-value, + > .kv-key, + > .kv-value { display: table-cell; + padding-bottom: 0; + padding-top: 0; } - + .kv-key { padding-right: 1em; } @@ -51,4 +56,4 @@ .kv-key { text-align: right; } -} \ No newline at end of file +} diff --git a/site-root/sass/slate/modules/_people.scss b/site-root/sass/slate/modules/_people.scss index c6e271f8b..a9937d3a0 100644 --- a/site-root/sass/slate/modules/_people.scss +++ b/site-root/sass/slate/modules/_people.scss @@ -2,40 +2,42 @@ @include background-size(cover); } -$roster-avatar-size: 64px; -$roster-item-width: $roster-avatar-size * 1.3125; -$roster-font-size: $font-size * .6875; -$roster-line-height: $line-height * .8; - .roster { + display: grid; + grid-gap: 1em .5em; + grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; - + li { - display: inline-block; - font-size: $roster-font-size; - height: $roster-avatar-size + (($roster-line-height * $roster-font-size) * 2.5); - line-height: $roster-line-height; + font-size: .75em; + line-height: 1.25; list-style: none; - margin-bottom: .75em; - overflow: hidden; + min-width: 0; text-align: center; - vertical-align: text-bottom; - width: $roster-item-width; } - + a { + display: block; text-decoration: none; - + &:hover, &:focus { text-decoration: underline; } } - + .avatar { + border-radius: 100%; + box-shadow: 0 1px 2px rgba(0,0,0,.1); margin: 0 auto .25em; } + + .name { + display: block; + overflow: hidden; + text-overflow: ellipsis; + } } .about-bio { @@ -43,7 +45,7 @@ $roster-line-height: $line-height * .8; color: inherit; font-size: 1em; } - + .well-title { color: $heading-color; font-size: 1.2em; @@ -58,4 +60,4 @@ $roster-line-height: $line-height * .8; text-overflow: ellipsis; white-space: nowrap; } -} \ No newline at end of file +} diff --git a/site-root/sass/slate/modules/_tag-list.scss b/site-root/sass/slate/modules/_tag-list.scss new file mode 100644 index 000000000..ba0dad9aa --- /dev/null +++ b/site-root/sass/slate/modules/_tag-list.scss @@ -0,0 +1,30 @@ +.tag-list { + list-style: none; + margin: 0; + padding: 0; + + >li { + display: inline-block; + } + + .tag { + background-color: rgba($link-color, .05); + border-radius: .25em; + display: block; + font-size: .875em; + margin-bottom: .25em; + padding: 0 .5em; + text-decoration: none; + + &:hover, + &:focus { + background-color: rgba($link-color, .1); + } + } + + .tag-count { + color: rgba($text-color, .4); + font-size: .75em; + font-weight: bold; + } +} From 56a2ecbbd90f0b7612cbd39860d71779daaa09d0 Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 12:45:54 -0500 Subject: [PATCH 02/34] feat: update Section obj to provide posts and tags --- php-classes/Slate/Courses/Section.php | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/php-classes/Slate/Courses/Section.php b/php-classes/Slate/Courses/Section.php index a6c3b60cf..68a642b40 100644 --- a/php-classes/Slate/Courses/Section.php +++ b/php-classes/Slate/Courses/Section.php @@ -186,7 +186,13 @@ class Section extends \VersionedRecord ,'class' => Mapping::class ,'contextClass' => __CLASS__ ] - ]; + ,'BlogPosts' => [ + 'type' => 'one-many' + ,'class' => BlogPost::class + ,'contextClass' => __CLASS__ + ,'foreign' => 'ContextID' + ] + ]; public static $validators = [ 'Course' => [ @@ -204,6 +210,10 @@ class Section extends \VersionedRecord ,'StudentsCount' => [ 'method' => 'getStudentsCount' ] + ,'BlogPosts' + ,'Tags' => [ + 'method' => 'getTags' + ] ]; public static $sorters = [ @@ -411,6 +421,26 @@ public function getCohorts() } } + public function getTags() + { + $posts = $this->BlogPosts; + $tags = []; + $result = []; + + foreach ($posts as $post) { + $tags = array_merge($tags, $post->Tags); + } + + $result = array_reduce($tags, function($result, $tag) + { + $count = $result[$tag->Handle] != NULL ? $result[$tag->Handle]['count'] : 0; + $result[$tag->Handle] = array_merge($tag->getData(), ['count' => count]); + return $result; + }); + + return $result; + } + // search SQL generators protected static function getTeacherSearchSql($term, $condition) { From 2052d15e3f002733690f49f75f651e0992f4bdaf Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 12:49:27 -0500 Subject: [PATCH 03/34] fix: add BlogPost class to imports --- php-classes/Slate/Courses/Section.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php-classes/Slate/Courses/Section.php b/php-classes/Slate/Courses/Section.php index 68a642b40..9de73610d 100644 --- a/php-classes/Slate/Courses/Section.php +++ b/php-classes/Slate/Courses/Section.php @@ -12,6 +12,7 @@ use Emergence\People\User; use Emergence\Locations\Location; use Emergence\Connectors\Mapping; +use Emergence\CMS\BlogPost; use Slate\Term; use Slate\Courses\SectionParticipant; From 06fea31a5610ed7aca19bc5d942b1a3da25f9925 Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 13:44:11 -0500 Subject: [PATCH 04/34] fix: correct tag counting --- php-classes/Slate/Courses/Section.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-classes/Slate/Courses/Section.php b/php-classes/Slate/Courses/Section.php index 9de73610d..a2fae7380 100644 --- a/php-classes/Slate/Courses/Section.php +++ b/php-classes/Slate/Courses/Section.php @@ -435,7 +435,7 @@ public function getTags() $result = array_reduce($tags, function($result, $tag) { $count = $result[$tag->Handle] != NULL ? $result[$tag->Handle]['count'] : 0; - $result[$tag->Handle] = array_merge($tag->getData(), ['count' => count]); + $result[$tag->Handle] = array_merge($tag->getData(), ['count' => $count+1]); return $result; }); From 7b33300482f414b959be3bd47cd92053dfdb26ff Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 15:38:40 -0500 Subject: [PATCH 05/34] feat: implement tag links in section template --- html-templates/sections/courseSection.tpl | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index 637afd8c0..b0632b5ac 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -186,19 +186,7 @@ Tags - {$tags = array( - "lorem ipsum", - "dolor sit amet", - "consectetur", - "adipiscing", - "elit borbi consequat", - "turpis", - "feugiat", - "foo", - "bar", - "baz", - "qux" - );} + {$tags = $Section->getTags()} {* if there's 10 or more, show the first five and collapse the rest *} {if count($tags) >= 10} @@ -212,7 +200,7 @@ @@ -227,7 +215,7 @@ From a4b4c4f41c9b8ff0224714d505912d9b1d9cbf51 Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 17:32:05 -0500 Subject: [PATCH 06/34] fix: improve function name --- html-templates/sections/courseSection.tpl | 2 +- php-classes/Slate/Courses/Section.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index b0632b5ac..a73c72862 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -186,7 +186,7 @@ Tags - {$tags = $Section->getTags()} + {$tags = $Section->findBlogTags()} {* if there's 10 or more, show the first five and collapse the rest *} {if count($tags) >= 10} diff --git a/php-classes/Slate/Courses/Section.php b/php-classes/Slate/Courses/Section.php index a2fae7380..5074192e8 100644 --- a/php-classes/Slate/Courses/Section.php +++ b/php-classes/Slate/Courses/Section.php @@ -422,7 +422,7 @@ public function getCohorts() } } - public function getTags() + public function findBlogTags() { $posts = $this->BlogPosts; $tags = []; From 9071a2fb1897915bbaa33632c2c828ee5a894d0c Mon Sep 17 00:00:00 2001 From: BillClinton Date: Tue, 14 Dec 2021 17:37:55 -0500 Subject: [PATCH 07/34] feat: move code from template to Class function --- html-templates/sections/courseSection.tpl | 20 ++++---------------- php-classes/Slate/Courses/Section.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index a73c72862..848fee2ef 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -39,22 +39,10 @@ 'conditions' => [] ]; - $sectionTeacherIds = array_map(function($Teacher) { - return $Teacher->ID; - }, $this->scope['Section']->ActiveTeachers); - - $latestTeacherPost = \Emergence\CMS\BlogPost::getAllPublishedByContextObject($this->scope['Section'], array_merge_recursive($options, [ - 'conditions' => [ - 'AuthorID' => [ - 'operator' => 'IN', - 'values' => $sectionTeacherIds - ] - ], - 'limit' => 1 - ])); - - if (count($latestTeacherPost)) { - $this->scope['latestTeacherPost'] = $latestTeacherPost[0]; + $latestTeacherPost = $this->scope['Section']->findLatestTeacherPost(); + + if ($latestTeacherPost) { + $this->scope['latestTeacherPost'] = $latestTeacherPost; $options['conditions'][] = sprintf('ID != %u', $this->scope['latestTeacherPost']->ID); } diff --git a/php-classes/Slate/Courses/Section.php b/php-classes/Slate/Courses/Section.php index 5074192e8..b4acd9f40 100644 --- a/php-classes/Slate/Courses/Section.php +++ b/php-classes/Slate/Courses/Section.php @@ -442,6 +442,25 @@ public function findBlogTags() return $result; } + public function findLatestTeacherPost() + { + $sectionTeacherIds = array_map(function($Teacher) { + return $Teacher->ID; + }, $this->ActiveTeachers); + + $latestTeacherPost = \Emergence\CMS\BlogPost::getAllPublishedByContextObject($this, array_merge_recursive([ + 'conditions' => [ + 'AuthorID' => [ + 'operator' => 'IN', + 'values' => $sectionTeacherIds + ] + ], + 'limit' => 1 + ])); + + return $latestTeacherPost[0]; + } + // search SQL generators protected static function getTeacherSearchSql($term, $condition) { From 952da6fc024cb85200b60308196d153018413c8c Mon Sep 17 00:00:00 2001 From: BillClinton Date: Thu, 23 Dec 2021 13:19:07 -0500 Subject: [PATCH 08/34] feat: update count variable to reflect new name --- html-templates/sections/courseSection.tpl | 36 ++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index 848fee2ef..6a9e9bf29 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -32,29 +32,45 @@ scope['limit'] = 10; - $options = [ - 'limit' => $this->scope['limit'], - 'offset' => $_GET['offset'] ?: 0, - 'calcFoundRows' => 'yes', - 'conditions' => [] - ]; + $conditions = []; $latestTeacherPost = $this->scope['Section']->findLatestTeacherPost(); if ($latestTeacherPost) { $this->scope['latestTeacherPost'] = $latestTeacherPost; - $options['conditions'][] = sprintf('ID != %u', $this->scope['latestTeacherPost']->ID); + $conditions[] = sprintf('ID != %u', $this->scope['latestTeacherPost']->ID); } - $this->scope['blogPosts'] = \Emergence\CMS\BlogPost::getAllPublishedByContextObject($this->scope['Section'], $options); + $this->scope['blogPosts'] = $this->scope['Section']->findBlogPosts($conditions, $this->scope['limit'], $_GET['offset'] ?: 0 ); $this->scope['total'] = DB::foundRows(); + + {* if (!empty($_GET['blog_tag'])) { + $Tag = Tag::getByHandle($_GET['blog_tag']); + + if (!$Tag) { + throw new Exception('tag not found'); + } + + $this->scope['blogTag'] = $Tag; + } else { + $Tag = null; + } *} + ?>