Jump to content

gRegor

Members
  • Posts

    125
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by gRegor

  1. https://github.com/gRegorLove/ProcessWire-IndieAuth This module allow users to sign in to your site using IndieAuth: IndieAuth is a way to use your own domain name to sign in to websites. It works by linking your website to one or more authentication providers such as Twitter or Google, then entering your domain name in the login form on websites that support IndieAuth. This module has two different functions: IndieAuth Authentication After a user enters their domain name and successfully authenticates, they will be redirected back to your site and the session variable indieauth_domain will be set. You can then use this session variable to customize your site for the user or offer additional functionality. Note: The user is not logged in to ProcessWire at this point. ProcessWire Authentication If you would like to allow users to log in to ProcessWire using IndieAuth, you will need to make a few changes to the user profile. Add a field named website Add that field to the user template Update the User Profile module to make the website field user-editable The user will need to set their domain name in their user profile before they can log in with IndieAuth. Setup After installing the module, copy the template file extra/templates/indieauth.php into your site/templates/ directory. In the admin area, add the new indieauth template. On the "URLs" tab for the template, check "HTTPS only." Create and publish a new ProcessWire page using this template, e.g. https://example.com/auth/ The included template is a minimal, sample template that covers both of the functionalities described above. You can expand the template or integrate it into your existing templates as needed. For more information about the sign-in form and how the verification works, please refer to https://indieauth.com/developers Notes This module does not create user records if they do not exist already.
  2. Ah, did not realize that. Good to know. A shortcut findIDs() method in Pages.php seems like a good idea to add.
  3. PageFinder has a findIDs() method that sets the returnVerbose attribute. It doesn't set loadPages attribute, but I presume when returnVerbose is off it automatically does not return pages. Untested, but this should work: (Oops. Doesn't work. See below.) $pages->findIDs($selector);
  4. What's your use-case for passing a path to jQuery like that, or was it a made up example? base64 enc/de-coding shouldn't be necessary if you're using the get parameters. It might be easier to just pass in the script name "jquery-2.2.0.js" and use $config to build the URLs to the file, though.
  5. Thanks for those links. I understand better now that getMatchQuery() is used for searching subfields in pages. That function in my fieldtype is adapted from the Comments module and is working as expected. I realized the find() method is for searching the webmention fields outside of a $page context, i.e. in the Webmentions Manager (also adapted from the Comments module). I ended up adding a find() method to my main Webmention module that finds the first FieldtypeWebmention and calls its find() method directly, so I can call $Webmention->find('author_email=user@example.com') and get the WebmentionArray I want.
  6. If I'm understanding you correctly, I think you can use $this->input->urlSegment1 (2, 3, and so on). within your ___execute* method. I don't think you'd have to worry about any encoding or decoding.
  7. Thanks, that is useful. I had not thought about WebmentionArray. I did some more testing last night and $page->Webmention->find('author_email=user@example.com') did actually work, for searching within the field on a specific page. I also got $pages->find('Webmentions.author_email=user@example.com') to work, regardless of the functions I mentioned. I guess I thought I had to implement some "find" functionality, but it's actually inherited from WireArray. I should be more clear with my desired use-case: I need a simple boolean check whether someone has sent a webmention previously or not. I was thinking I'd do that by searching, getting a WebmentionArray of results, then using the count() method to see if there's 0 or 1+. I could achieve the same results with the $pages->find selector above, but perhaps there is an even more direct way (short of writing a direct SQL query)?
  8. Solved below I'm wondering how to properly implement a find() method for a Fieldtype so it can be used in an API-y way. When I set up the FieldtypeWebmentions I used FieldtypeComment as a basis. It includes a find() method, which I'm not entirely sure I understand, or is even what I need. What I want to do (from elsewhere in my code) is perform a search across the webmention field for a certain author email, like: $page->Webmention->find('author_email=user@example.com'); I've looked at http://processwire.com/api/modules/ and the Fieldtype Map Marker as an example, but it is still a bit opaque to me what the Right Way™ is. Is it actually the getMatchQuery() method I need to implement? Thanks for any help!
  9. Fixed as of v1.1.1: I caught (and filed) a bug to be fixed: if you use the Webmentions Manager to try to manually process/delete a received webmention, it does not work currently. This doesn't affect the automatic processing, if you have that enabled, or manually processing from the page that received the webmention. Do feel free to try it out by sending a webmention to this post on my site: http://gregorlove.com/2016/02/quite-pleased-to-officially-release/
  10. Officially in the module directory! http://modules.processwire.com/modules/webmention/
  11. Version 1.1.0 is now released. It's been submitted to the module directory so should appear there soon. In the meantime, it's available on GitHub: https://github.com/gRegorLove/ProcessWire-Webmention. Please refer to the updated README there and let me know if you have any questions!
  12. Excellent! Thanks.
  13. I've set up a Process module that displays various views in the admin area. The contents of these views are built in the ___execute* functions, but I was wondering if anyone has any recommended practices for separating out the view "templates" into separate files. I suppose I could just put template files in the module's directory and require() them from the function calls, but wasn't sure if there's a better / more ProcessWire-y way to do it.
  14. And then I found FieldtypeSecureFile. Figures. https://processwire.com/talk/topic/10671-fieldtypesecurefile/
  15. I have a solution that 90% works, which is good enough for my needs. I have the complicated situation where there's an Images field, which needs to remain public, and a Documents field which needs to be protected in some situations. In my setup, I have a checkbox field is_member_page which is used to require authentication to view the page, so I've also used that in my hooks: # For files that should be protected, set the path to the .page-id files directory. Should auto-create the directory. $this->addHookAfter('PagefilesManager::path', function($event) { $page = $event->object->page; if ( $page->is_member_page ) { $event->return = dirname($event->return) . '/.' . $page->id . '/'; } }); I was using this next hook for a while, so the URL in the admin area pointed automatically to the download pass-through page. What I ran into is that this broke the preview in the Images field, though, so I opted against it. This means when I insert links to the files, I have to manually craft them. It's a minor inconvenience for being able to still preview and easily insert the images, though. # Optional; if you want to change the URL to automatically point to the download pass-through page. # Be sure to replace/set $YOUR_PAGE_ID as appropriate. $this->addHookAfter('PagefilesManager::url', function($event) { $page = $event->object->page; if ( $page->is_member_page ) { $event->return = wire('pages')->get($YOUR_PAGE_ID)->url . $event->object->page . '/' . $event->object->name; } }); This is where it gets a bit tricky, and violates DRY a bit. The above hooks affect the path and url for all file fields. I tried and tried, but I could not conditionally change them for only the Documents field while leaving the Images field. Instead, what I've done is checked if the inputfield is a FIle or an Image. If it's an image, I make a copy of it in the public folder, so it can be previewed in the backend (and used on the page ). $this->addHook('InputfieldFile::fileAdded', function($event) { if ( get_class($event->object) == 'InputfieldFile' ) { $file = $event->arguments(0); $path = $file->filename(); $page = $file->page; # if: member only page if ( $page->is_member_page ) { $secure_path = dirname(dirname($path)) . '/.' . $page->id . '/'; if ( !$file->copyToPath($secure_path) ) { $this->log->save('messages', "Error copying secure file to: {$secure_path}"); } } # end if } else if ( get_class($event->object) == 'InputfieldImage' ) { $file = $event->arguments(0); $path = $file->filename(); $page = $file->page; $public_dir = dirname(dirname($path)) . '/' . $page->id . '/'; # if: file does not exist in public dir yet; copy it if ( !file_exists($public_dir . $file->name) ) { if ( !$file->copyToPath($public_dir) ) { $this->log->save('messages', "Error copying file to: {$public_dir}"); } } # end if } }); Finally, to clean up my DRY mess, I make sure when an image is deleted from the protected directory, it's also deleted from the public directory. $this->addHook('InputfieldFile::processInputDeleteFile', function($event) { $file = $event->arguments(0); $path = $file->filename(); $page = $file->page; $public_path = dirname(dirname($path)) . '/' . $page->id . '/' . $file->name; if ( file_exists($public_path) ) { unlink($public_path); } }); My download pass-through page template is similar to the ones mentioned earlier in this thread, though I check the file extension and if it's a PDF I deliver it with MIME type application/pdf and not with Content-Disposition: attachment -- that way the PDF can be previewed in modern browsers, depending on the user's settings. (I can share this template too, if anyone is interested). Any feedback is welcome!
  16. Thanks for that PageArray trick. That works great and I think I can keep 2.5+ support. And thanks for the Github info!
  17. I'm working on adding a Webmention Manager to my module, using Comment Manager as the basis. I'm still on PW 2.5.3 and trying to build the module to work on 2.5+ (the only reason I haven't upgraded yet). I realized that the PaginatedArray class isn't in the 2.5.3 code, so was going to add backcompat code to the module. I was wondering when the PaginatedArray class was added to core, but having a hard time determining that. Is there an easy way to find out, short of searching through each of the version tags on Github? Perhaps the doc parameter @since could be added to the doc comments, so I could tell by looking at the master branch? While on the topic, is the best way to include such backcompat to check for the existence of the class and then include it if it doesn't exist? Edit: Hmm, so I'm realizing that the updates adding PaginatedArray and WirePaginatable go deeper than I expected. For example, I cannot use the MarkupPagerNav because it expects a PageArray input, not my WebmentionArray (which implements WirePaginatable). Perhaps it's best to just make my module 2.6+, unless someone has some good advice for backwards compatibility.
  18. Thanks for the kind words, Johannes. Yes, making the plugin more flexible about the fields it looks for URLs in is something I've been thinking about. I chose "body" since it seems the most common field people will have in their templates, but even that is not guaranteed. I think I will add a module configuration that will accept a comma-separated list of fields to check for URLs. If the template has one of those fields, it will parse for URLs and send webmentions to them. This is something I already need for my site. For example, my notes have a separate field for the in-reply-to URL, so I currently cannot webmention those URLs automatically. This module will work with your Brid.gy backfeed, by the way. P.S. I made a reply to this note and sent a webmention.
  19. Yes, if the WordPress site supports webmentions. If the site doesn't support webmentions and does support pingback, this module will fallback to sending a pingback. There are WordPress plugins to add webmention support,. See http://indiewebcamp.com/WordPress for more info. As I understand it, there's actually two plugins to get the full features: Webmention and Semantic Linkbacks. The latter gives you more user-friendly text for linkbacks (of all types). There's a pretty active group of WordPress users in the indiewebcamp community and I know they'd love to help anyone get set up with these plugins. Feel free to stop by the IRC for any help: http://indiewebcamp.com/IRC
  20. Thanks, teppo! Yeah, I was looking over the code after I posted and realized I should be using prepared statements. D'oh! I'll make that fix quickly Yeah, the WireHttp shim gives you an indication how long I've been working on this, heh. I decided to leave it in for now so that the module could be 2.5-compatible; I think my WireHttp PR didn't make it in until 2.6 (not sure which version, exactly). Perhaps I could perform a version check in the code and if it's before X, use the shim, otherwise use the core version.
  21. An example of some cool things this enables: If you add some simple microformats to your HTML, the recipient of a webmention can parse out the content of your post and display it as a comment on their own site; federated commenting! For example, I posted this silly physics pun on my site, sent a webmention to the URL it was in-reply-to, and the recipient's website parsed the microformats to display my comment.
  22. Updated 2018-05-06: Version 2.0.0 released Updated 2017-03-27: Version 1.1.3 released Updated 2016-04-11: Version 1.1.2 released Updated 2016-02-26: Officially in the module directory! http://modules.processwire.com/modules/webmention/ Updated 2016-02-25: Version 1.1.0 is now released. It's been submitted to the module directory so should appear there soon. In the meantime, it's available on GitHub: https://github.com/gRegorLove/ProcessWire-Webmention. Please refer to the updated README there and let me know if you have any questions! ------------ Original post: This is now out of date. I recommend reading the official README. I've been working on this one for a while. It's not 100%, but it is to the point I'm using it on my own site, so it's time for me to release it in beta. Once I finish up some of the features described below, I will submit it to the modules directory as a stable plugin. For now, you can install from Github. It works on PW2.5. I haven't tested on PW2.6, but it should work there. Feedback and questions are welcome. I'm in the IRC channel #processwire as well as #indiewebcamp if you have any questions about this module, webmention, or microformats. Thanks to Ryan for the Comments Fieldtype which helped me a lot in the handling of webmentions in the admin area. ProcessWire Webmention Module Webmention is a simple way to automatically notify any URL when you link to it on your site. From the receiver's perspective, it is a way to request notification when other sites link to it. Version 1.0.0 is a stable beta that covers webmention sending, receiving, parsing, and display. An easy admin interface for received webmentions is under development, as well as support for the Webmention Vouch extension. Features * Webmention endpoint discovery * Automatically send webmentions asynchronously * Automatically receive webmentions * Process webmentions to extract microformats Requirements * php-mf2 and php-mf2-cleaner libraries; bundled with this package and may optionally be updated using Composer. * This module hooks into the LazyCron module. Installation Github: https://github.com/gRegorLove/ProcessWire-Webmention Installing the core module named "Webmention" will automatically install the Fieldtype and Inputfield modules included in this package. This module will attempt to add a template and page named "Webmention Endpoint" if the template does not exist already. The default location of this endpoint is http://example.com/webmention-endpoint After installing the module, create a new field of type "Webmentions" and add it to the template(s) you want to be able to support webmentions. Sending Webmentions When creating or editing a page that has the Webmentions field, a checkbox "Send Webmentions" will appear at the bottom. Check this box and any URLs linked in the page body will be queued up for sending webmentions. Note: you should only check the "Send Webmentions" box if the page status is "published." Receiving Webmentions This module enables receiving webmentions on any pages that have have "Webmentions" field, by adding the webmention endpoint as an HTTP Link header. If you would like to specify a custom webmention endpoint URL, you can do so in the admin area, Modules > Webmention. Processing Webmentions (beta) Currently no webmentions are automatically processed. You will need to browse to the page in the backend, click "Edit," and scroll to the Webmentions field. There is a dropdown for "Visibility" and "Action" beside each webmention. Select "Process" to parse the webmention for microformats. A better interface for viewing/processing all received webmentions in one place is under development. Displaying Webmentions (beta) Within your template file, you can use `$page->Webmentions->render()` [where "Webmentions" is the name you used creating the field] to display a list of approved webmentions. As with the Comments Fieldtype, you can also generate your own output. The display functionality is also under development. Logs This module writes two logs: webmentions-sent and webmentions-received. Vouch The Vouch anti-spam extension is still under development. IndieWeb The IndieWeb movement is about owning your data. It encourages you to create and publish on your own site and optionally syndicate to third-party sites. Webmention is one of the core building blocks of this movement. Learn more and get involved by visiting http://indiewebcamp.com. Further Reading * http://indiewebcamp.com/webmention * http://indiewebcamp.com/comments-presentation * http://indiewebcamp.com/reply
  23. +1 for allowing original capitalization. To avoid name collisions on Windows, the unique filename comparison could still use the lowercase filename, but append n to the original filename instead of the lowercase filename. processwire.gif, ProcessWire.gif, and PROCESSWIRE.GIF would become: processwire.gif, ProcessWire-1.gif, and PROCESSWIRE-2.GIF Alternately, is there a way in PHP to detect the file system's case-sensitivity?
  24. Per discussion with @renobird in IRC, I've decided to add child pages that also use ProcessDocumentation and then grandchild pages that use template: documentation. Then the ___execute() method will display the page contents and/or a list of links to the sub-pages as appropriate.
  25. I've set up a basic module, ProcessDocumentation, that is intended to add a tree of documentation pages under the Admin page. The module doesn't actually use templates to display anything. The ___execute method displays a list of links to the documentation pages (child pages). Clicking on one of those, the ___executeView method uses the URL segment to load the appropriate page contents and display it. This works OK when using the default theme. There is no expanded sub-menu (e.g. hovering over Setup > Templates displaying the list of templates), but the top-level "Documentation" page is clickable which displays the list of pages. In Reno, though, those links are in the sidebar and the top-level links are click-to-expand. I'm having difficulty displaying the child documentation pages in Reno when clicking to expand, without using a template file. It looks like in AdminThemeRenoHelpers::renderSideNavItem() method it's loading child pages that are viewable. Since the documentation pages don't use a template, they're not getting populated. I've toyed around with the 'nav' key in the getModuleInfo() but that doesn't seem to work. I also tried out renderListJSON() and ___executeNavJSON() which I saw in some other modules, but I'm pretty sure those aren't used in this context, but in the search methods. I could add a template file, of course, but I don't want to render an entirely different layout. I just want to display the regular admin interface with the documentation page body in the main content area. Any suggestions?
×
×
  • Create New...