From 7bab13881d59b569be0f89c29197d3892bbf4d4f Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Wed, 3 Aug 2016 10:03:05 -0400 Subject: [PATCH] bounty program 1.0 --- controller/action/BountyActions.class.php | 17 +++--- controller/action/ContentActions.class.php | 22 +++++-- data/i18n/en.yaml | 5 ++ model/Post.class.php | 10 ++++ posts/faq/bounties.md | 26 ++++++++ view/template/bounty/_meta.php | 4 ++ view/template/bounty/list.php | 69 +++++++++++----------- view/template/bounty/show.php | 34 ++++++++--- view/template/content/faq.php | 30 +++++++--- view/template/form/_select.php | 7 +++ view/template/nav/_footer.php | 26 ++++---- web/scss/_blog.scss | 2 +- web/scss/_bounty.scss | 13 ++-- web/scss/_hero.scss | 8 ++- 14 files changed, 187 insertions(+), 86 deletions(-) create mode 100644 posts/faq/bounties.md create mode 100644 view/template/bounty/_meta.php create mode 100644 view/template/form/_select.php diff --git a/controller/action/BountyActions.class.php b/controller/action/BountyActions.class.php index a062dde3..2af7e18d 100644 --- a/controller/action/BountyActions.class.php +++ b/controller/action/BountyActions.class.php @@ -6,16 +6,18 @@ class BountyActions extends Actions public static function executeList() { + $allBounties = Post::find(ROOT_DIR . '/posts/bounty'); + + $allCategories = ['' => ''] + Post::collectMetadata($allBounties, 'category'); + $allStatuses = ['' => ''] + Post::collectMetadata($allBounties, 'status'); + $selectedStatus = static::param('status'); $selectedCategory = static::param('category'); - $filters = array_filter(['category' => $selectedCategory, 'status' => $selectedStatus]); - $allBounties = Post::find(ROOT_DIR . '/posts/bounty'); - - $allCategories = array_unique(array_map(function(Post $post) { - $metadata = $post->getMetadata(); - return isset($metadata['category']) ? $metadata['category'] : null; - }, $allBounties)); + $filters = array_filter([ + 'category' => $selectedCategory && isset($allCategories[$selectedCategory]) ? $selectedCategory : null, + 'status' => $selectedStatus && isset($allStatuses[$selectedStatus]) ? $selectedStatus : null + ]); $bounties = $filters ? Post::filter($allBounties, $filters) : $allBounties; @@ -32,6 +34,7 @@ class BountyActions extends Actions return ['bounty/list', [ 'bounties' => $bounties, 'categories' => $allCategories, + 'statuses' => $allStatuses, 'selectedCategory' => $selectedCategory, 'selectedStatus' => $selectedStatus ]]; diff --git a/controller/action/ContentActions.class.php b/controller/action/ContentActions.class.php index a71b34d5..19f5de99 100644 --- a/controller/action/ContentActions.class.php +++ b/controller/action/ContentActions.class.php @@ -23,9 +23,9 @@ class ContentActions extends Actions public static function executeFaq() { - $posts = Post::find(static::VIEW_FOLDER_FAQ); + $allPosts = Post::find(static::VIEW_FOLDER_FAQ); - $groupNames = [ + $allCategories = array_merge(['' => ''] + Post::collectMetadata($allPosts, 'category'), [ 'getstarted' => 'Getting Started', 'install' => 'Installing LBRY', 'running' => 'Running LBRY', @@ -35,17 +35,27 @@ class ContentActions extends Actions 'policy' => 'Policies', 'developer' => 'Developers', 'other' => 'Other Questions', - ]; + ]); + $selectedCategory = static::param('category'); + $filters = array_filter([ + 'category' => $selectedCategory && isset($allCategories[$selectedCategory]) ? $selectedCategory : null, + ]); - $groups = array_fill_keys(array_keys($groupNames), []); + asort($allCategories); + + $posts = $filters ? Post::filter($allPosts, $filters) : $allPosts ; + + + $groups = array_fill_keys(array_keys($allCategories), []); foreach($posts as $post) { - $groups[isset($groupNames[$post->getCategory()]) ? $post->getCategory() : 'other'][] = $post; + $groups[$post->getCategory()][] = $post; } return ['content/faq', [ - 'groupNames' => $groupNames, + 'categories' => $allCategories, + 'selectedCategory' => $selectedCategory, 'postGroups' => $groups ]]; } diff --git a/data/i18n/en.yaml b/data/i18n/en.yaml index a2acef52..d27f5a8b 100644 --- a/data/i18n/en.yaml +++ b/data/i18n/en.yaml @@ -8,6 +8,11 @@ # # +bounty: + list: + noresult: No matching bounties found. + show: + completednotice: This bounty has already been completed and can no longer be claimed. description: allowed: Download/install the latest version of LBRY for %os%. faq: Frequently asked questions about LBRY. diff --git a/model/Post.class.php b/model/Post.class.php index 147e9b15..1988104a 100644 --- a/model/Post.class.php +++ b/model/Post.class.php @@ -343,6 +343,16 @@ class Post return strtolower(preg_replace('#^\d+\-#', '', basename(trim($filename), '.md'))); } + public static function collectMetadata(array $posts, $field) + { + $values = array_unique(array_map(function(Post $post) use($field) { + $metadata = $post->getMetadata(); + return isset($metadata[$field]) ? $metadata[$field] : null; + }, $posts)); + sort($values); + return array_combine($values, $values); + } + public static function getSlugMap($postType) { if (!isset(static::$slugMap[$postType])) diff --git a/posts/faq/bounties.md b/posts/faq/bounties.md new file mode 100644 index 00000000..cabb2995 --- /dev/null +++ b/posts/faq/bounties.md @@ -0,0 +1,26 @@ +--- +title: How does the Bounty Program work? +category: policy +--- + +You can earn LBRY Credits for completing tasks as part of the LBRY Bounty Program. + +### What bounties are available? + +All bounties can be seen on the [bounty home page](/bounty). + +### How do I claim a bounty? + +To claim a bounty, please email [bounty@lbry.io](mailto:bounty@lbry.io). Please include a link to the bounty. If it is programming related, please include a link to the pull request. + +### How do I get compensated? + +People who complete bounties are awarded LBRY credits. These credits will be transferred to a wallet address of your choice and are yours with no restrictions to do as you like. + +### I have questions about a specific bounty or want assistance in completing a bounty. + +The best place to get real-time help is our [Slack channel](https://slack.lbry.io). You can also email our bounty team [bounty@lbry.io](mailto:bounty@lbry.io). + +### I want to complete a bounty that is not listed. + +Send an email our bounty team at [bounty@lbry.io](mailto:bounty@lbry.io). \ No newline at end of file diff --git a/view/template/bounty/_meta.php b/view/template/bounty/_meta.php new file mode 100644 index 00000000..8b195c05 --- /dev/null +++ b/view/template/bounty/_meta.php @@ -0,0 +1,4 @@ +
+ + +
\ No newline at end of file diff --git a/view/template/bounty/list.php b/view/template/bounty/list.php index b504526b..23c0f5bf 100644 --- a/view/template/bounty/list.php +++ b/view/template/bounty/list.php @@ -2,7 +2,7 @@ false]) ?>
-
+

LBRY Bounties

@@ -12,23 +12,22 @@

Bounties

+

Complete challenges and earn LBRY Credits. Learn more.

- + 'category', + 'choices' => $categories, + 'selected' => $selectedCategory + ]) ?>
@@ -39,31 +38,31 @@
- + +
+ + getMetadata() ?> + + +
+ +

{{bounty.list.noresults}}

+
diff --git a/view/template/bounty/show.php b/view/template/bounty/show.php index 99ee8f01..69a1f573 100644 --- a/view/template/bounty/show.php +++ b/view/template/bounty/show.php @@ -2,15 +2,31 @@
-
-
+
+

+
+ $metadata]) ?> +
+ +
{{bounty.show.completednotice}}
+ + +
+
+

Claim This Bounty

+ +

Bounty Questions?

+ +
+
true]) ?> diff --git a/view/template/content/faq.php b/view/template/content/faq.php index b4ecc2b0..19fc4262 100644 --- a/view/template/content/faq.php +++ b/view/template/content/faq.php @@ -4,13 +4,29 @@

{{page.faq.header}}

- $posts): ?> -

- - - + +
+ + 'category', + 'choices' => $categories, + 'selected' => $selectedCategory + ]) ?> +
+ + + $('#faq-filter-form').change(function() { $(this).submit(); }); + + + $posts): ?> + +

+ + + +
diff --git a/view/template/form/_select.php b/view/template/form/_select.php new file mode 100644 index 00000000..dc3193a7 --- /dev/null +++ b/view/template/form/_select.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/view/template/nav/_footer.php b/view/template/nav/_footer.php index 49623c84..0a88f89f 100644 --- a/view/template/nav/_footer.php +++ b/view/template/nav/_footer.php @@ -4,18 +4,20 @@ $isDark]) ?> - diff --git a/web/scss/_blog.scss b/web/scss/_blog.scss index ee46c99f..e57bd408 100644 --- a/web/scss/_blog.scss +++ b/web/scss/_blog.scss @@ -97,7 +97,7 @@ margin-right: auto; max-width: $max-post-content-width; margin-bottom: $spacing-vertical * 2; - a[href] + a[href]:not([class]) { @include anchor($color-primary); } diff --git a/web/scss/_bounty.scss b/web/scss/_bounty.scss index 4a783465..a878c801 100644 --- a/web/scss/_bounty.scss +++ b/web/scss/_bounty.scss @@ -1,15 +1,14 @@ -.bounty-tile -{ +.bounty-tile { display: block; margin: 0 10px $spacing-vertical; padding: 10px; background: #eee; - &:hover - { + &:hover { cursor: pointer; } - .icon-mega - { +} - } +.bounty-status-complete .bounty-award +{ + text-decoration: line-through; } \ No newline at end of file diff --git a/web/scss/_hero.scss b/web/scss/_hero.scss index d39a0257..e985cc64 100644 --- a/web/scss/_hero.scss +++ b/web/scss/_hero.scss @@ -59,6 +59,10 @@ background: black url(/img/dark.png) no-repeat top center fixed; min-height: 420px; @include background-size(cover); + &.hero-img-short + { + min-height: 200px; + } &:before { position: absolute; @@ -69,7 +73,7 @@ display: block; top: 0; left: 0; - } + } } .hero-quote { @@ -96,7 +100,7 @@ padding-left: 10px; padding-right: 10px; } -@media (max-width: $mobile-width-threshold) +@media (max-width: $mobile-width-threshold) { .hero {