Skip to content

Commit

Permalink
Merge branch '2.x-dev' into v2/refactor-search-index-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 7, 2024
2 parents 4942992 + eef01ee commit 99a235f
Show file tree
Hide file tree
Showing 32 changed files with 159 additions and 139 deletions.
1 change: 0 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ This serves two purposes:

### Changed
- Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task.
- Updated the documentation article component to support existing `$document` instance.

### Deprecated
- for soon-to-be removed features.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## About HydePHP

HydePHP is a new Static Site Builder focused on writing content, not markup. With Hyde, it is easy to create static
HydePHP is a Static Site Generator focused on writing content, not markup. With Hyde, it is easy to create static
websites, blogs, and documentation pages using Markdown and (optionally) Laravel's Blade.

Operated entirely through the command-line, HydePHP provides developers with a fast and efficient way to create high-quality websites with ease.
Expand Down
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@php
$document ??= \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page);
$article ??= \Hyde\Framework\Features\Documentation\SemanticDocumentationArticle::make($page);
@endphp

<article id="document" itemscope itemtype="https://schema.org/Article" @class([
'mx-auto lg:ml-8 max-w-3xl p-12 md:px-16 max-w-[1000px] min-h-[calc(100vh_-_4rem)]',
config('markdown.prose_classes', 'prose dark:prose-invert'),
'torchlight-enabled' => $document->hasTorchlight()])>
'torchlight-enabled' => $article->hasTorchlight()])>
@yield('content')

<header id="document-header" class="flex items-center flex-wrap justify-between prose-h1:mb-3">
{{ $document->renderHeader() }}
{{ $article->renderHeader() }}
</header>
<section id="document-main-content" itemprop="articleBody">
{{ $document->renderBody() }}
{{ $article->renderBody() }}
</section>
<footer id="document-footer" class="flex items-center flex-wrap mt-8 prose-p:my-3 justify-between text-[90%]">
{{ $document->renderFooter() }}
{{ $article->renderFooter() }}
</footer>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class PublishHomepageCommand extends Command

/** @var array<string, array{name: string, description: string, group: string}> */
protected array $options = [
'welcome'=> [
'welcome' => [
'name' => 'Welcome',
'description' => 'The default welcome page.',
'group' => 'hyde-welcome-page',
],
'posts'=> [
'posts' => [
'name' => 'Posts Feed',
'description' => 'A feed of your latest posts. Perfect for a blog site!',
'group' => 'hyde-posts-page',
],
'blank'=> [
'blank' => [
'name' => 'Blank Starter',
'description' => 'A blank Blade template with just the base layout.',
'group' => 'hyde-blank-page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct()
parent::__construct(static::routeKey(), [
'title' => 'Search',
'navigation' => ['hidden' => true],
'document' => $this->makeDocument(),
'article' => $this->makeArticle(),
], view: 'hyde::pages.documentation-search');
}

Expand All @@ -61,7 +61,7 @@ protected static function anotherSearchPageExists(): bool
}

/** @experimental Fixes type issue {@see https://github.com/hydephp/develop/commit/37f7046251b8c0514b8d8ef821de4ef3d35bbac8#commitcomment-135026537} */
protected function makeDocument(): SemanticDocumentationArticle
protected function makeArticle(): SemanticDocumentationArticle
{
return SemanticDocumentationArticle::make(new DocumentationPage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
interface BlogPostSchema extends PageSchema
{
public const BLOG_POST_SCHEMA = [
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
interface PageSchema extends FrontMatterSchema
{
public const PAGE_SCHEMA = [
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
interface AuthorSchema extends BlogPostSchema
{
public const AUTHOR_SCHEMA = [
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
interface FeaturedImageSchema extends BlogPostSchema
{
public const FEATURED_IMAGE_SCHEMA = [
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
interface NavigationSchema extends PageSchema
{
public const NAVIGATION_SCHEMA = [
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
];
}
18 changes: 9 additions & 9 deletions packages/framework/src/Support/Filesystem/MediaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ public function getMimeType(): string
// See if we can find a mime type for the extension instead of
// having to rely on a PHP extension and filesystem lookups.
$lookup = [
'txt' => 'text/plain',
'md' => 'text/markdown',
'txt' => 'text/plain',
'md' => 'text/markdown',
'html' => 'text/html',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'gif' => 'image/gif',
'json' => 'application/json',
'js' => 'application/javascript',
'xml' => 'application/xml',
'js' => 'application/javascript',
'xml' => 'application/xml',
];

if (isset($lookup[$extension])) {
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Support/Models/RouteListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function __construct(Route $route)
public function toArray(): array
{
return [
'page_type' => $this->stylePageType($this->route->getPageClass()),
'page_type' => $this->stylePageType($this->route->getPageClass()),
'source_file' => $this->styleSourcePath($this->route->getSourcePath()),
'output_file' => $this->styleOutputPath($this->route->getOutputPath()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/MarkdownServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function test_raw_html_tags_are_stripped_by_default()

public function test_raw_html_tags_are_not_stripped_when_explicitly_enabled()
{
config(['markdown.allow_html' =>true]);
config(['markdown.allow_html' => true]);
$markdown = '<p>foo</p><style>bar</style><script>hat</script>';
$service = new MarkdownService($markdown);
$html = $service->parse();
Expand Down
22 changes: 22 additions & 0 deletions packages/framework/tests/Feature/Services/HydeSmartDocsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,28 @@ public function test_the_documentation_article_view()
$this->assertStringContainsString('<p>Hello world.</p>', $rendered);
}

public function test_the_documentation_article_view_with_existing_variable()
{
$rendered = view('hyde::components.docs.documentation-article', [
'page' => $page = $this->makePage(),
'article' => new class($page) extends SemanticDocumentationArticle
{
public function __construct(DocumentationPage $page)
{
parent::__construct($page);
}

public function renderHeader(): HtmlString
{
return new HtmlString('<h1>Custom Header</h1>');
}
},
])->render();

$this->assertStringContainsString('<h1>Custom Header</h1>', $rendered);
$this->assertStringContainsString('<p>Hello world.</p>', $rendered);
}

protected function makeArticle(string $sourceFileContents = "# Foo\n\nHello world."): SemanticDocumentationArticle
{
$this->file('_docs/foo.md', $sourceFileContents);
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/MediaFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'length' => 7,
'mimeType' => 'text/plain',
], MediaFile::make('foo.txt')->toArray());
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/ProjectFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
], ProjectFileTestClass::make('foo.txt')->toArray());
}

Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/SourceFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'pageClass' => HydePage::class,
], SourceFile::make('foo.txt')->toArray());
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/BreadcrumbsComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testCanRender()
$view = Mockery::mock(\Illuminate\View\View::class);
$mock = Mockery::mock(Factory::class);
$mock->shouldReceive('make')->once()->with('hyde::components.breadcrumbs')->andReturn($view);
app()->singleton('view', fn () =>$mock);
app()->singleton('view', fn () => $mock);
View::swap($mock);

$this->assertSame($view, (new BreadcrumbsComponent())->render());
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Unit/Pages/BaseHydePageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected function setUp(): void
]),
'share' => null,
]));
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () =>$mock);
app()->bind('view', fn () =>$mock);
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () => $mock);
app()->bind('view', fn () => $mock);

Render::swap(new RenderData());
}
Expand Down
48 changes: 24 additions & 24 deletions packages/framework/tests/Unit/SchemaContractsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,42 @@ class SchemaContractsTest extends UnitTestCase
public function testSchemasAreNotAccidentallyChanged()
{
$this->assertSame([
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
], PageSchema::PAGE_SCHEMA);

$this->assertSame([
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
], NavigationSchema::NAVIGATION_SCHEMA);

$this->assertSame([
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
], BlogPostSchema::BLOG_POST_SCHEMA);

$this->assertSame([
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
], AuthorSchema::AUTHOR_SCHEMA);

$this->assertSame([
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
], FeaturedImageSchema::FEATURED_IMAGE_SCHEMA);
}

Expand Down
Loading

0 comments on commit 99a235f

Please sign in to comment.