Jump to content

Please remove white space from quotes, messy posts a problem


chilihead

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

I've already posted a quick fix some post ago, and it work!

eg: https://laltroweb.it/_script/test.html

 

Put this in "Search engine optimization; Google analitics" (yes, i use this place for many script...)

<script type="text/javascript">
$('p').each(function() {
    var $this = $(this);
    if($this.html().replace(/\s|&nbsp;/g, '').length == 0)
        $this.remove();
});
</script>

and test result.

 

Link to comment
Share on other sites

1 minute ago, chilihead said:

So it would change it visually and not the database post? That may be a better solution even. Does it mess with whitespace in the body? Because I don't want to do that. Just the ends in posts and quotes (top/bottom). Thanks a lot!

The code in this post

2 hours ago, laltroweb.it said:

I've already posted a quick fix some post ago, and it work!

eg: https://laltroweb.it/_script/test.html

 

Put this in "Search engine optimization; Google analitics" (yes, i use this place for many script...)


<script type="text/javascript">
$('p').each(function() {
    var $this = $(this);
    if($this.html().replace(/\s|&nbsp;/g, '').length == 0)
        $this.remove();
});
</script>

and test result.

 

Would mess with the body of posts - it removes every blank paragraph on the page, which might lead to some unintended side effects.

Link to comment
Share on other sites

If you only want to strip blank lines from the start and end of the quotes, and you only want to run it client side (so it will only work on browsers with js enabled, will show up differently in the editor, and can't be easily bypassed, the following script should what you want.

$(".ipsComment .ipsType_richText .ipsQuote_contents").each(function() {
  //Whitespace at start
  while (true) {
    var p = $(this).children("p:first-child");
    if (p.length && !p.children().length && !p.text().trim().length) {
      p.remove();
    } else {
      break;
    }
  }
  //Whitespace at end
  while (true) {
    var p = $(this).children("p:last-child");
    if (p.length && !p.children().length && !p.text().trim().length) {
      p.remove();
    } else {
      break;
    }
  }
});

 

Link to comment
Share on other sites

Thanks! I suppose you could do that for the post body as well (that covers all apps and statuses?) with an edit? And where does that file go?

I'll see where this suggestion goes and probably utilize the best solution when that time comes but that looks promising thanks for doing that.

Link to comment
Share on other sites

1 hour ago, chilihead said:

Thanks! I suppose you could do that for the post body as well (that covers all apps and statuses?) with an edit? And where does that file go?

I'll see where this suggestion goes and probably utilize the best solution when that time comes but that looks promising thanks for doing that.

Currently, it's set up for quotes on anything that is classed as a comment (including status update comments, if you have quotes in there).

To use it, wrap it with

(function ($) {
  $(document).ready(function() {
  	//Put the code here
  });
})(jQuery);

Then you have a few options

  • If you've got an installation with dev mode enabled, you can convert it into a plugin by creating a new plugin, then saving the above content to a file with a .js extension in /plugins/<your plugin>/dev/js
  • If not, you could add the code to the Google Analytics section, wrapped in
    <script> /*The code here*/ </script>

     

Link to comment
Share on other sites

Oh neat. My guy has been swamped so he hasn't had chance to tackle this. Is this approach generally preferred to server side?

Some observations:

  • Neat! :)
  • Edit notices will break the bottom routine, would need to wrap the post content in another div and apply to that to overcome this
  • br would be good to add to this
Link to comment
Share on other sites

7$ for a mod for white space? .... so, i prefer white space (or simple jquery. or css...) :|

sometime i ask to myself why i don't migrate to wordpress :/

EG: This is a plugin (dev by me) with more than 20k active installations: https://it.wordpress.org/plugins/my-custom-css/

Here, instead, we pay for ipb (ok, grat app ip great support - i'm happy to pay for this), themes (mmm... many themes now want 6months renew and many other as asked new feed with ips4 - imho, this is not a great way), and many many plugin (yes, i know, some plugins need many hours of work and support, but many others are very little apps and isn't possible to ask ***$ for any little plugins in marketplace)!

-

a big "bravo" to all user who make free apps (or donationware etc) - eg: BIM41 and his chatbox app!

i am real sorry for this, but this is my opinion.

Link to comment
Share on other sites

May have to buy this one, thanks @motomac ! Would prefer that it only apply to the forum though, if it went back and changed the way existing articles on other parts of the suite looked it could potentially take some clean up time. Not sure if that would be the case though.

For some reason around 75% of posts come though with many of these extra paragraphs from what we're seeing and all have to be manually edited constantly. I'm not sure why it's happening with the WYSIWYG editor here but regardless it must be intuitive to add these extra returns for many members. 

Link to comment
Share on other sites

3 hours ago, IP15.5 said:

if it went back and changed the way existing articles on other parts of the suite looked it could potentially take some clean up time. Not sure if that would be the case though.

Not sure if this is retroactive, but even so, I'm more interested in the setting that removes the top and bottom and not the middle. Blogs and statuses have this issue too with members posting embeds, etc. Mostly the tailing line. 

I could see having it not work with articles though, with databases and fields and such and someone might want the full white space setting on but to not affect articles with special formatting. But he didn't mention articles, only blogs and statuses for the future, possibly. Maybe gallery image body.

Of course the biggest problem is the forum and comments of apps and this takes care of it brilliantly!

One more question @motomac, will this work for reviews? They use the comment container correct?

Link to comment
Share on other sites

@chilihead no, this plugin doesn't rebuild old posts currently. It cleans comments content before putting it into the DB. So even if you uninstall this plugin, posts which where created when it was installed, will stay beautiful :) 

I'm working on an update, where an admin can choose, which type of content to clean (comments and posts, blog entries, gallery image descriptions, statuses).

Link to comment
Share on other sites

Woot! What about article/database comments are those the regular comment container? And not sure if you saw my question about reviews, are those the comment container as well? I'm not sure. Great work sir!

And this is a modest fee, the cost of a cheap beer. Keep up the good work. One of the best mods out there because it fixes a seriously annoying problem.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...