LBRY Bounties
@@ -12,23 +12,22 @@Bounties
+Complete challenges and earn LBRY Credits. Learn more.
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 @@ +
Complete challenges and earn LBRY Credits. Learn more.