Jump to content

Please remove white space from quotes, messy posts a problem


chilihead

Recommended Posts

Posted

I would agree that many members somehow inadvertently add the spacing and a high percentage of posts and quotes need to be manually edited on a daily basis to remove the gaps - sometimes many lines. 

  • Replies 51
  • Created
  • Last Reply
Posted

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.

 

Posted

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!

Posted
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.

Posted

Yeah I don't want to do that. I want to keep

 

 

the space above this, as it could likely be intended or mess up formatting, and remove the below space

 

 

 

Posted

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;
    }
  }
});

 

Posted

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.

Posted
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>

     

Posted

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
Posted

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.

Posted
On 1/28/2016 at 5:46 PM, Martin1980 said:

No reply from the IPS devs so far... Not good. 

Seriously, this thread seems unanimous & rather popular... would be nice to get an official nod that this is being looked at....

Posted

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. 

Posted

@motomac is the mod is retroactive, if not, will running the rebuild tool fix on all posts? (Not even sure if there is an IPS rebuild tool.)
And does this changes posts in the db, or the look of posts only, like another mod that was posted using js?
Thanks a lot!

Posted
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?

Posted

@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).

Posted

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.

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...