mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
add faq categories, fix up a few faqs
This commit is contained in:
parent
283fef2a62
commit
656c39ec73
7 changed files with 109 additions and 63 deletions
|
@ -24,8 +24,28 @@ class ContentActions extends Actions
|
|||
public static function executeFaq()
|
||||
{
|
||||
$posts = Post::find(static::VIEW_FOLDER_FAQ);
|
||||
|
||||
$groupNames = [
|
||||
'getstarted' => 'Getting Started',
|
||||
'install' => 'Installing LBRY',
|
||||
'running' => 'Running LBRY',
|
||||
'wallet' => 'The LBRY Wallet',
|
||||
'hosting' => 'Hosting Content',
|
||||
'mining' => 'Mining LBC',
|
||||
'developer' => 'Developers',
|
||||
'other' => 'Other Questions',
|
||||
];
|
||||
|
||||
$groups = array_fill_keys(array_keys($groupNames), []);
|
||||
|
||||
foreach($posts as $post)
|
||||
{
|
||||
$groups[isset($groupNames[$post->getCategory()]) ? $post->getCategory() : 'other'][] = $post;
|
||||
}
|
||||
|
||||
return ['content/faq', [
|
||||
'posts' => $posts
|
||||
'groupNames' => $groupNames,
|
||||
'postGroups' => $groups
|
||||
]];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Post
|
|||
const SORT_DATE_DESC = 'sort_date_desc';
|
||||
|
||||
protected static $slugMap = [];
|
||||
protected $slug, $title, $author, $date, $markdown, $contentText, $contentHtml, $cover, $category;
|
||||
protected $slug, $title, $author, $date, $markdown, $contentText, $contentHtml, $cover, $postType, $category;
|
||||
protected $isCoverLight = false;
|
||||
|
||||
public static function load($relativeOrAbsolutePath)
|
||||
|
@ -15,7 +15,7 @@ class Post
|
|||
{
|
||||
throw new LogicException('Cannot load a post without a path.');
|
||||
}
|
||||
$category = $pathTokens[count($pathTokens) - 2];
|
||||
$postType = $pathTokens[count($pathTokens) - 2];
|
||||
$filename = $pathTokens[count($pathTokens) - 1];
|
||||
$isRelative = $relativeOrAbsolutePath[0] != '/';
|
||||
$slug = strpos($filename, '.md') !== false ? static::getSlugFromFilename($filename) : $filename;
|
||||
|
@ -27,7 +27,7 @@ class Post
|
|||
{
|
||||
if ($isRelative)
|
||||
{
|
||||
$slugMap = static::getSlugMap($category);
|
||||
$slugMap = static::getSlugMap($postType);
|
||||
if (isset($slugMap[$slug]))
|
||||
{
|
||||
return static::load($slugMap[$slug]);
|
||||
|
@ -37,12 +37,12 @@ class Post
|
|||
}
|
||||
|
||||
list($ignored, $frontMatter, $content) = explode('---', file_get_contents($path), 3);
|
||||
return new static($category, $slug, Spyc::YAMLLoadString(trim($frontMatter)), trim($content));
|
||||
return new static($postType, $slug, Spyc::YAMLLoadString(trim($frontMatter)), trim($content));
|
||||
}
|
||||
|
||||
public function __construct($category, $slug, $frontMatter, $markdown)
|
||||
public function __construct($postType, $slug, $frontMatter, $markdown)
|
||||
{
|
||||
$this->category = $category;
|
||||
$this->postType = $postType;
|
||||
$this->slug = $slug;
|
||||
$this->markdown = $markdown;
|
||||
$this->title = isset($frontMatter['title']) ? $frontMatter['title'] : null;
|
||||
|
@ -50,6 +50,7 @@ class Post
|
|||
$this->date = isset($frontMatter['date']) ? new DateTime($frontMatter['date']) : null;
|
||||
$this->cover = isset($frontMatter['cover']) ? $frontMatter['cover'] : null;
|
||||
$this->isCoverLight = isset($frontMatter['cover-light']) && $frontMatter['cover-light'] == 'true';
|
||||
$this->category = isset($frontMatter['category']) ? $frontMatter['category'] : null;
|
||||
}
|
||||
|
||||
public static function find($folder, $sort = null)
|
||||
|
@ -75,7 +76,7 @@ class Post
|
|||
|
||||
public function getRelativeUrl()
|
||||
{
|
||||
return $this->category . '/' . $this->slug;
|
||||
return $this->postType . '/' . $this->slug;
|
||||
}
|
||||
|
||||
public function getSlug()
|
||||
|
@ -108,6 +109,11 @@ class Post
|
|||
return $this->isCoverLight;
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function getContentText($wordLimit = null, $appendEllipsis = false)
|
||||
{
|
||||
if ($this->markdown && !$this->contentText)
|
||||
|
@ -130,21 +136,21 @@ class Post
|
|||
|
||||
public function getPostNum()
|
||||
{
|
||||
return array_search($this->getSlug(), array_keys(static::getSlugMap($this->category)));
|
||||
return array_search($this->getSlug(), array_keys(static::getSlugMap($this->postType)));
|
||||
}
|
||||
|
||||
public function getPrevPost()
|
||||
{
|
||||
$slugs = array_keys(Post::getSlugMap($this->category));
|
||||
$slugs = array_keys(Post::getSlugMap($this->postType));
|
||||
$postNum = $this->getPostNum();
|
||||
return $postNum === false || $postNum === 0 ? null : Post::load($this->category . '/' . $slugs[$postNum-1]);
|
||||
return $postNum === false || $postNum === 0 ? null : Post::load($this->postType . '/' . $slugs[$postNum-1]);
|
||||
}
|
||||
|
||||
public function getNextPost()
|
||||
{
|
||||
$slugs = array_keys(Post::getSlugMap($this->category));
|
||||
$slugs = array_keys(Post::getSlugMap($this->postType));
|
||||
$postNum = $this->getPostNum();
|
||||
return $postNum === false || $postNum >= count($slugs)-1 ? null : Post::load($this->category . '/' . $slugs[$postNum+1]);
|
||||
return $postNum === false || $postNum >= count($slugs)-1 ? null : Post::load($this->postType . '/' . $slugs[$postNum+1]);
|
||||
}
|
||||
|
||||
public function hasAuthor()
|
||||
|
@ -157,6 +163,11 @@ class Post
|
|||
return $this->date !== null;
|
||||
}
|
||||
|
||||
public function hasPrevNext()
|
||||
{
|
||||
return $this->postType == 'post';
|
||||
}
|
||||
|
||||
public function getAuthorName()
|
||||
{
|
||||
switch(strtolower($this->author))
|
||||
|
@ -298,16 +309,16 @@ class Post
|
|||
return strtolower(preg_replace('#^\d+\-#', '', basename(trim($filename), '.md')));
|
||||
}
|
||||
|
||||
public static function getSlugMap($category)
|
||||
public static function getSlugMap($postType)
|
||||
{
|
||||
if (!isset(static::$slugMap[$category]))
|
||||
if (!isset(static::$slugMap[$postType]))
|
||||
{
|
||||
static::$slugMap[$category] = [];
|
||||
foreach(glob(ROOT_DIR . '/posts/' . $category . '/*.md') as $file)
|
||||
static::$slugMap[$postType] = [];
|
||||
foreach(glob(ROOT_DIR . '/posts/' . $postType . '/*.md') as $file)
|
||||
{
|
||||
static::$slugMap[$category][static::getSlugFromFilename($file)] = $file;
|
||||
static::$slugMap[$postType][static::getSlugFromFilename($file)] = $file;
|
||||
}
|
||||
}
|
||||
return static::$slugMap[$category];
|
||||
return static::$slugMap[$postType];
|
||||
}
|
||||
}
|
|
@ -3,17 +3,30 @@ title: How do I see the list of API functions I can call, and how do I call them
|
|||
category: developer
|
||||
---
|
||||
|
||||
Here is an example script to get the documentation for the various API calls. To use any of the functions displayed, just provide any specified arguments in a dictionary. Many (though not all) of the calls are the same as those for bitcoin core, which are documented [here](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list).
|
||||
Ensure that `lbrycrd` is running with the `-server` flag, which enables the JSON-RPC API. Then use one of the following methods to make API calls.
|
||||
|
||||
If for some reason you can't get lbrycrd-cli working to make these calls, make sure you passed -server when starting lbrycrd. If it still doesn't work, you can use this command:
|
||||
Many (though not all) of the calls are the same as those for bitcoin core, which are
|
||||
documented [here](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list). To see the full list of API calls, use the `help` API call.
|
||||
|
||||
curl --user USER:PASSWORD --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "COMMAND", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9245/
|
||||
## lbrycrd-cli
|
||||
|
||||
USER and PASSWORD can be found in your lbrycrd.conf file, COMMAND can be any of the supported methods like getbalance or getnewaddress. 9245 is the default port used, but if you chose a custom port for the server, you'll need to use that instead. If the command accepts parameters, they can be passed inside the params array [].
|
||||
lbrycrd-cli help
|
||||
|
||||
## curl
|
||||
|
||||
curl --user USER:PASSWORD --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "help", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9245/
|
||||
|
||||
- `USER` and `PASSWORD` can be found in your lbrycrd.conf file.
|
||||
- The `method` field can be any of the supported methods like `getbalance` or `getnewaddress`.
|
||||
- `9245` is the default port used, but if you chose a custom port for the server, you'll need to use that instead.
|
||||
- If the command accepts parameters, they can be passed inside the `params` array.
|
||||
|
||||
See Also: [important directories](https://lbry.io/faq/lbry-directories).
|
||||
|
||||
Note: the LBRY API can only be used while either the app or lbrynet-daemon is running.
|
||||
## Python
|
||||
|
||||
Here is an example script to get the documentation for the various API calls.
|
||||
To use any of the functions displayed, just provide any specified arguments in a dictionary.
|
||||
|
||||
import sys
|
||||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
|
|
@ -3,4 +3,6 @@ title: How do I check my mining balance?
|
|||
category: mining
|
||||
---
|
||||
|
||||
You can use `lbrycrd-cli getbalance`, or `lbrycrd-cli getwalletinfo` for more detailed information. It takes 100 confirmed blocks (roughly a bit over 4 hours) for mined LBC to show up in your confirmed balance, but you can see these credits in your immature balance in getwalletinfo.
|
||||
You can use `lbrycrd-cli getbalance`, or `lbrycrd-cli getwalletinfo` for more detailed information.
|
||||
It takes 100 confirmed blocks (roughly a bit over 4 hours) for mined LBC to show up in your confirmed balance,
|
||||
but you can see these credits in your immature balance in getwalletinfo.
|
||||
|
|
26
view/template/content/_postNav.php
Normal file
26
view/template/content/_postNav.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<nav class="content prev-next row-fluid">
|
||||
<div class="prev span6">
|
||||
<?php if ($prevPost = $post->getPrevPost()): ?>
|
||||
<div class="prev-next-label">
|
||||
<a href="/<?php echo $prevPost->getRelativeUrl() ?>" class="link-primary">‹ Previous</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<a href="/<?php echo $prevPost->getRelativeUrl() ?>">
|
||||
<?php echo htmlentities($prevPost->getTitle()) ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="next span6">
|
||||
<?php if ($nextPost = $post->getNextPost()): ?>
|
||||
<div class="prev-next-label">
|
||||
<a href="/<?php echo $nextPost->getRelativeUrl() ?>" class="link-primary">Next ›</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<a class="prev-next-title" href="/<?php echo $nextPost->getRelativeUrl() ?>">
|
||||
<?php echo htmlentities($nextPost->getTitle()) ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</nav>
|
|
@ -3,11 +3,14 @@
|
|||
<main>
|
||||
<section class="content content-readable spacer2">
|
||||
<h1>Frequently Asked Questions</h1>
|
||||
<?php foreach($postGroups as $group => $posts): ?>
|
||||
<h2><?php echo $groupNames[$group] ?></h2>
|
||||
<?php foreach($posts as $post): ?>
|
||||
<div class="spacer1">
|
||||
<a href="<?php echo $post->getRelativeUrl() ?>" class="link-primary"><?php echo $post->getTitle() ?></a>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
</main>
|
||||
<?php echo View::render('nav/footer') ?>
|
||||
|
|
|
@ -19,45 +19,16 @@
|
|||
</header>
|
||||
|
||||
<div class="post-content">
|
||||
|
||||
<section class="content spacer2">
|
||||
<div class="post-content">
|
||||
<?php echo $post->getContentHtml() ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<nav class="content prev-next row-fluid">
|
||||
<div class="prev span6">
|
||||
<?php if ($prevPost = $post->getPrevPost()): ?>
|
||||
<div class="prev-next-label">
|
||||
<a href="/<?php echo $prevPost->getRelativeUrl() ?>" class="link-primary">‹ Previous</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<a href="/<?php echo $prevPost->getRelativeUrl() ?>">
|
||||
<?php echo htmlentities($prevPost->getTitle()) ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if($post->hasPrevNext()): ?>
|
||||
<?php echo View::render('content/_postNav', ['post' => $post]) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="next span6">
|
||||
<?php if ($nextPost = $post->getNextPost()): ?>
|
||||
<div class="prev-next-label">
|
||||
<a href="/<?php echo $nextPost->getRelativeUrl() ?>" class="link-primary">Next ›</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<a class="prev-next-title" href="/<?php echo $nextPost->getRelativeUrl() ?>">
|
||||
<?php echo htmlentities($nextPost->getTitle()) ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<?php if ($post->hasAuthor()): ?>
|
||||
<?php echo View::render('content/_postAuthor', [
|
||||
'post' => $post
|
||||
]) ?>
|
||||
<?php echo View::render('content/_postAuthor', ['post' => $post]) ?>
|
||||
<?php endif ?>
|
||||
|
||||
</main>
|
||||
|
|
Loading…
Add table
Reference in a new issue