Hashtags
- Edited
djalmasi Yep, that’s how it is designed for now. It was conflicting with formatting and image changes from other extensions. To prevent the conflict you can no longer have a hashtag in the same paragraph as formatted text or images.
Hashtags are now only allowed in plain text paragraphs like this one or on a new line by themselves.
Due to lack of spare time, this is the best I can do right now. At least it will no longer break images or anything.
Thanks for the update
Arnold Honestly I didn't even know people used underscores in hashtags. I had to go over to Twitter just now to see. Sure enough, people do sometimes use underscores. I'm betting this is fixable by again tweaking the regular expression. I just have to tell the regular expression, "allow underscores." I wonder if this part stopped working when I changed the regular expression so that all/most languages are supported? I'm not sure.
@010101this is great have you consider the possibility of building an extension based on this. We can pull out the search result and display a list a related post links based on hashtag
This extension isn't compatible with beta 14+. Unless someone wants to adopt this extension, or give me the exact code to patch it, I think it'll have to go to the extension graveyard . From what I've read so far I assume it is due to Mithril 2.0. More specifically due to config no longer being a lifecyle hook? I don't have the skills to update it even though it's probably relatively simple. I tried making some guesses after reading some docs, but no luck.
I feel bad because I do think there are several people that use this. But, we'll have to wait for a developer to possibly, one day, create a new hashtag extension. One that is probably way better than this one.
- Edited
010101 CommentPost.prototype.config
is now CommentPost.prototype.oncreate
and CommentPost.prototype.onupdate
. There's no longer an isInitalized
parameter, instead oncreate
is called once, and onupdate
is called for subsequent redraws.
Basically
extend(CommentPost.prototype, 'config', function (out, isInitialized, vnode) {
// [the code]
});
becomes
extend(CommentPost.prototype, 'oncreate', function (out, vnode) {
// [the code]
});
extend(CommentPost.prototype, 'onupdate', function (out, vnode) {
// [the code]
});
A function can be used to not repeat the code.
Or, when isInitialized
is used:
extend(CommentPost.prototype, 'config', function (out, isInitialized, vnode) {
if (isInitialized) return;
// [the code]
});
becomes
extend(CommentPost.prototype, 'oncreate', function (out, vnode) {
// [the code]
});
EDIT: ignore my previous edit referencing super
, it only applies if you were creating your own components.
clarkwinkelmann Thank you for being willing to help! The problem is that this is one of those extensions done the wrong way where everything is in the extend.php file.
This isn't working:
<script>
flarum.core.compat.extend.extend(flarum.core.compat['components/CommentPost'].prototype, 'oncreate', function (output, context) {
if (context.customExtLastContentHtml !== context.contentHtml) {
// [the code]
context.customExtLastContentHtml = context.contentH tml;
});
</script>
Original code that did work until beta 14:
<script>
flarum.core.compat.extend.extend(flarum.core.compat['components/CommentPost'].prototype, 'config', function(output, isInitialized, context) {
if (context.customExtLastContentHtml !== context.contentHtml) {
// [the code]
context.customExtLastContentHtml = context.contentH tml;
});
</script>
010101 The arguments to oncreate are different than those to config. Replace the second argument with vnode
. Then, where you need to access the DOM element, use vnode.dom
Thanks to @clarkwinkelmann and @askvortsov this little extension will become compatible with beta 14 soon (as soon as I have a break where I can sit down at my computer).