-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension support #29
Open
doddo
wants to merge
12
commits into
jmacdotorg:master
Choose a base branch
from
doddo:instaplerd_support
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1112417
Make plerd use InstaPlerd::Post for jpeg files.
doddo 6ba208f
Make plerdwatcher act on jpegs too
doddo f421ebe
Add Extension support
doddo 4fea8e3
Add test for extensions
doddo 2175ad5
Clean up superflous code and redundant imports
doddo 7f6d3ae
Make test work tomorrow too :)
doddo 4a966b5
Make trigger regex match file ending only.
doddo fe877ff
Don't need to split a list for extensions
doddo 5bc6ba2
Add extension_preferences option
doddo 99fb208
Improve Plerd.pm doc on extension related methods
doddo d878bd8
Print extension error message if present.
doddo 8a58182
Make TestExtension do something
doddo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package TestExtension; | ||
use Plerd::Post; | ||
use Moose; | ||
use strict; | ||
|
||
use 5.010; | ||
|
||
use warnings FATAL => 'all'; | ||
|
||
extends "Plerd::Post"; | ||
|
||
sub file_type { | ||
'dm'; | ||
} | ||
|
||
around 'body' => sub { | ||
my $orig = shift; | ||
my $self = shift; | ||
if (@_){ | ||
# "Setter" | ||
my $body = shift; | ||
|
||
# first time body is called, reverse it! | ||
$body = reverse $body unless $self->$orig; | ||
|
||
$self->$orig($body); | ||
} else { | ||
# "Getter" | ||
$self->$orig(); | ||
} | ||
}; | ||
|
||
1; | ||
|
||
|
||
=head1 NAME | ||
|
||
TestExtension - A L<Plerd::Post> extension to showcase the extension capabilities of L<Plerd>. | ||
|
||
=head1 DESCRIPTION | ||
|
||
This extension doesn't do anything truly useful. It's sole purpose is showcasing the extension capabilities. | ||
|
||
What it does in fact do, though, is reversing the body of the document (the first time it's set). | ||
|
||
It's rather useless. | ||
|
||
=head1 OBJECT ATTRIBUTES | ||
|
||
=head2 Read-only attributes, set during construction | ||
|
||
=over | ||
|
||
=item file_type | ||
|
||
A regex-compatible string which indicate what file types to associate with the Extension. | ||
This is set to "dm" (which happens to be "md" spelled backwards) | ||
|
||
=item body | ||
|
||
The original L<Plerd::Post> body, except that the first time this attribute is set, it gets reversed. | ||
|
||
=back | ||
|
||
=head2 Other attributes | ||
|
||
All other attributes are inherited from L<Plerd::Post> Please consult that documentation for their docs. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title: A very special source file | ||
|
||
|
||
It's only special because it's file type is .dm which is .md backwards. This is to see if it gets processed by an extension. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please expand this TextExtension module so that it actually writes a file into the docroot, based on the source file that it reads? That will allow the tests to pass without needing to modify the "+4" magic number (which is has changed to "+5" in more recent master-branch work, anyway) and would also serve to demonstrate a little more clearly how an extension might actually work in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! It does actually publish a file to the docroot, but it doesn't do that until the test extension is explicitly loaded into plerd, thats's at line 344, and you'll find the assert further down that it actually does publish a file, even though the source file was
.dm
.But you are right that it's sort of a no-op. Let me see if I can make it do something more interesting.