Martijn Geerts Posted June 16, 2013 Share Posted June 16, 2013 This is great! Thinking loud here: If you add tags to images, (lets say: cars, beaches or skyscrapers) then you could easily create albums. [[gallery tag=skyscrapers]] 3 Link to comment Share on other sites More sharing options...
arjen Posted June 17, 2013 Share Posted June 17, 2013 [[gallery tag=skyscrapers" sort="-created" limit="10" paginate="true]] 3 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted June 18, 2013 Share Posted June 18, 2013 Now we have this, I can imagine we have a "snippet" bucket somewhere were we can share some high quality "snippets". 4 Link to comment Share on other sites More sharing options...
kongondo Posted June 18, 2013 Share Posted June 18, 2013 Now we have this, I can imagine we have a "snippet" bucket somewhere were we can share some high quality "snippets". Yeah. We can start by raiding Soma's Gist 3 Link to comment Share on other sites More sharing options...
ryan Posted June 21, 2013 Author Share Posted June 21, 2013 I just posted version 5 of Hanna Code. The primary additions here are: Predefined (default) attribute values There is a new Attributes field present in the Hanna Code editor. From here you can define what attributes your PHP or Javascript Hanna Code expects. This can also be used to set default values for attributes. Use of this is optional. However, I think it's a good idea to use it as it helps communicate what the options are for a given Hanna Code. It also saves you some code as you can assume your attributes will be defined as variables, ready to access. The main listing page now shows Hanna Codes with their attributes so that they can be copied/pasted into your body text with all attribute options known and ready to fill in. Support for Export and Import of Hanna Codes Now you can export any Hanna code and import it somewhere else using copy/paste. You'll see the Export option when editing a Hanna Code. You'll see the Import option on the main listing page. Below is a predefined Hanna Code you can import if you'd like: Jumplinks Hanna Code (example for import) This Hanna code is meant to be used in your body copy. It collects all the headline tags in the text and turns them into anchor jump links while outputting a linked table of contents. It will put the table of contents wherever you type the Hanna code. See the anchor jump links on this page for an example of what this Hanna Code does. Import Data: !HannaCode:jumplinks:eyJuYW1lIjoianVtcGxpbmtzIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxuZm9yPVwiaDIgaDNcIlxuaGNfYXR0cipcL1xuJGZvciA9IHN0cl9yZXBsYWNlKCcsJywgJyAnLCAkZm9yKTtcclxuJ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In0=/!HannaCode Usage Examples: [[jumplinks]] Locates all h2 and h3 headlines, turns them into anchors, and generates a table of contents. This is the default behavior with no attributes. [[jumplinks for=h2]] Here we specify a 'for' attribute. It produces the same behavior as above except only anchors h2 headlines. [[jumplinks for=h2 h4]] Same as above except only anchors h2 and h4 headlines. 7 Link to comment Share on other sites More sharing options...
kongondo Posted June 21, 2013 Share Posted June 21, 2013 Nice! Thx for the update. Link to comment Share on other sites More sharing options...
Sinmok Posted July 2, 2013 Share Posted July 2, 2013 Mr Ryan, Do you have any plans to add some syntax highlighting for the code editor area? Great module, but I think a highlighter would be the cherry on top Something like CodeMirror would be awesome. Cheers. 1 Link to comment Share on other sites More sharing options...
Soma Posted July 2, 2013 Share Posted July 2, 2013 Not sure what you mean with highlighting. In TinyMCE code? There's already CodeMirror included just not installed for TinyMCE by default so you have to enable it. https://github.com/ryancramerdesign/ProcessWire/tree/master/wire/modules/Inputfield/InputfieldTinyMCE/tinymce-3.5.8/plugins/codemagic Link to comment Share on other sites More sharing options...
Sinmok Posted July 2, 2013 Share Posted July 2, 2013 No no, not TinyMCE. Here's the SS from the modules page: In the 'Code' box, there's no syntax highlighting for the code that is in the textarea. I'm just suggesting that the code in the textarea has syntax highlighting as you type to help prevent users from making an error when writing their code in that box. 1 Link to comment Share on other sites More sharing options...
WillyC Posted July 2, 2013 Share Posted July 2, 2013 needs to sholud have.type hintings, debuger and code.completion two 3 Link to comment Share on other sites More sharing options...
kongondo Posted July 2, 2013 Share Posted July 2, 2013 needs to sholud have.type hintings, debuger and code.completion two Hehe Link to comment Share on other sites More sharing options...
ryan Posted July 6, 2013 Author Share Posted July 6, 2013 Makes sense to me. The only thing is that PW core doesn't come with an Inputfield that does this, so it would be an external 3rd party dependency... something I'd like to avoid. So what I'll probably do is make the Inputfield type configurable so that you could tell it to use some future code-editing Inputfield instead of InputfieldTextarea. 3 Link to comment Share on other sites More sharing options...
diogo Posted July 18, 2013 Share Posted July 18, 2013 I posted my first Hanna Code here http://processwire.com/talk/topic/1182-module-image-tags/?p=40015 1 Link to comment Share on other sites More sharing options...
alevine Posted July 19, 2013 Share Posted July 19, 2013 I just downloaded 0.0.7 from the modules page. On install, I get: Module Install - TextformatterHannaCode Created Page: /processwire/setup/hanna-code/ Module Auto Install: ProcessHannaCode BLOB/TEXT column 'code' can't have a default value If I got to setup/Hanna, I get: Table 'pwire.hanna_code' doesn't exist I also get the same error message when trying to uninstall. EDIT: line 436 of TextformatterHannaCode, I removed "default '' " and it installed fine. I don't think will cause any unexpected issues... i'm using mysql, if that matters (567 I think) 1 Link to comment Share on other sites More sharing options...
ryan Posted July 20, 2013 Author Share Posted July 20, 2013 It sounds like your version of MySQL won't accept default values for a text field. I've not heard of that before. Perhaps it is some MySQL setting that I've not seen before. Seems like if it won't accept a default value (which we specify a blank string) then it could only be null as a default. Not that it matters much, but I'd prefer the blank string since there is no use for a null here. I agree that removing the default that you did shouldn't cause any issues. I'm curious to see if this issue turns up for anyone else. Link to comment Share on other sites More sharing options...
alevine Posted July 20, 2013 Share Posted July 20, 2013 It sounds like your version of MySQL won't accept default values for a text field. I've not heard of that before. Perhaps it is some MySQL setting that I've not seen before. Seems like if it won't accept a default value (which we specify a blank string) then it could only be null as a default. Not that it matters much, but I'd prefer the blank string since there is no use for a null here. I agree that removing the default that you did shouldn't cause any issues. I'm curious to see if this issue turns up for anyone else. According to http://dev.mysql.com/doc/refman/5.6/en/blob.html, BLOB and TEXT fields cannot have a default value. 1 Link to comment Share on other sites More sharing options...
ryan Posted July 21, 2013 Author Share Posted July 21, 2013 Sometimes when I say text I actually mean varchar (since it is also a type of text field). But in this case, I think I must have just forgotten when writing the schema. My version of mysql (and apparently most people's) doesn't complain about a default value in a "text" field, for whatever reason. But I will correct this, as it's sure to come up again. Link to comment Share on other sites More sharing options...
alevine Posted July 21, 2013 Share Posted July 21, 2013 Sometimes when I say text I actually mean varchar (since it is also a type of text field). But in this case, I think I must have just forgotten when writing the schema. My version of mysql (and apparently most people's) doesn't complain about a default value in a "text" field, for whatever reason. But I will correct this, as it's sure to come up again. Which version are you running? EDIT: I did notice in the comments that this is an error on windows systems (which is my dev area), but more of a warning on others. This may be our differences. Link to comment Share on other sites More sharing options...
ryan Posted July 23, 2013 Author Share Posted July 23, 2013 I'm not at my desktop computer, but think it is MySQL 5.5.25 (under MAMP) that I'm running. But you are right that assigning the default value to the text field in this module's schema wasn't right, so I pushed a fix for it a couple days ago. Link to comment Share on other sites More sharing options...
dotnetic Posted August 2, 2013 Share Posted August 2, 2013 Is it possible to use Hanna Code directly in my template file or in PHP without using a field for it? For example Use directly: <?php include("./head.inc"); ?> <div class="container content"> <div class="row-fluid"> <a name="content"></a> [[newsdetails]] </div> </div> <?php include("./foot.inc"); ?> or with PHP: <?php include("./head.inc"); ?> <div class="container content"> <div class="row-fluid"> <a name="content"></a> <?php $hanna = $modules->get('TextformatterHannaCode'); $page->body = $hanna->render('[[newsdetails]]'); echo $page->body; ?> </div> </div> <?php include("./foot.inc"); ?> Link to comment Share on other sites More sharing options...
teppo Posted August 2, 2013 Share Posted August 2, 2013 @jmartsch: your PHP example seems like it should work properly, as far as I can tell. Have you actually tried this yet..? 1 Link to comment Share on other sites More sharing options...
ryan Posted August 3, 2013 Author Share Posted August 3, 2013 From the README file (given this, I think your example would work): Using Hanna Code from the API If you want to populate Hanna Code from the API, you can do so using the render() method, like this: $hanna = $modules->get('TextformatterHannaCode'); $page->body = $hanna->render($page->body); 1 Link to comment Share on other sites More sharing options...
kongondo Posted August 3, 2013 Share Posted August 3, 2013 I've tried both the Hanna Code docs example and jmartsch PHP example but no dice. They both don't work for me. Nothing gets written or output. No errors, nothing. What exactly are they meant to do? Write to Hanna or output from Hanna? I am interpreting "populate" as creating a Hanna Code block. I think I am wrong Link to comment Share on other sites More sharing options...
Soma Posted August 3, 2013 Share Posted August 3, 2013 I also tried, and it doesn't work. Further investigation is that the formatValue doesn't return but set $this->value; So get it fixed I need to comment out #178: //$this->value = ''; and change in render() method to instead return $this->value: public function render($value) { $this->formatValue(new NullPage(), new Field(), $value); return $this->value; } Don't know what Ryan smoked but I didn't first spotted it as it's really wierd wired. 1 Link to comment Share on other sites More sharing options...
apeisa Posted August 3, 2013 Share Posted August 3, 2013 It's render($field), not render([ ]). So jmartsch example is little off. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now