FANDOM


LockOldBlogs closes the commenting field on blog posts that haven't been commented on in the past 30 days, effectively allowing them to be automatically archived over time. Configuration options allow for exempting specific blogs so that they are never archived, changing the number of days old the blog must be to be archived, and translating the archive message into other languages.

Installation

See also: Help:Including additional JavaScript and CSS

To install this script on your wiki, admins should add the following to their MediaWiki:Common.js page:

importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:LockOldBlogs/code.js"
    ]
});

If importArticles() is already present

Note: If your wiki already has one importArticles() call of type: "script", you should not add another importArticles()! Instead, add "u:dev:MediaWiki:LockOldBlogs/code.js" to the array of articles. See Talk:LockOldBlogs for more information.

Configuration

There are some custom configuration options that you can use if you want to:

Variable name Description Default value
expiryDays The number of days after which a blog post should be archived. 30
expiryMessage The message that should be displayed to the user if commenting has been locked on the blog post. "This blog hasn\'t been commented on for over <expiryDays> days. There is no need to comment."
nonexpiryCategory The category to which you can add blog posts that should never expire. "Nonexpiry blogs"
expiryCategories only blog posts that are in categories on this list will expire (empty list means this option will be ignored) []

The syntax for using these configuration options goes like this:

window.LockOldBlogs = {
    expiryDays: number,
    expiryMessage: string,
    nonexpiryCategory: string,
    expiryCategories: [string, string, '...']
};

Example

Let's say you want to do the following:

  • Old blogs should be locked from commenting after 60 days
  • The message should say This blog is considered archived because it hasn't been commented on in over 60 days, please don't bump this blog!
  • All blogs in Category:Never archived blogs should never be locked/archived.

Here's the code you would put in your MediaWiki:Common.js with those configuration options:

window.LockOldBlogs = {
    expiryDays: 60,
    expiryMessage: "This blog is considered archived because it hasn\'t been commented on in over <expiryDays> days, please don\'t bump this blog!",
    nonexpiryCategory: "Never archived blogs"
};
 
 
importArticles({
    type: "script",
    articles: [
        "u:dev:MediaWiki:LockOldBlogs/code.js"
    ]
});

Notes:

  • Inside of the expiryMessage string, The apostrophe character ' must be replaced with \' and the quote character " must be replaced with \". This is called an "escape character" in JavaScript.
  • Inside of the expiryMessage string, you can (if you want to) use the <expiryDays> tag which will automatically be replaced with the expiryDays variable, which is 60 in this example.
  • Important: Notice that the importArticles() call comes after the configuration options!

Updates

27 February 2013
Mathmagician tweaked time calculation method. Blog posts with 0 comments can now expire based on the creation date of the blog post itself.
14 September 2012
Pecoes added configuration option for positive list of categories that expire at the request of Thailog
12 September 2012
Mathmagician added configuration options, tweaked the time calculation method, cleaned up code a bit
26 August 2012
Mathmagician fixed script to work with FANDOM's new Lazy Loading feature, originally posted the script at Community Central
A long time ago
Joeyaa first wrote this script. A version of it can be found here halfway down the page.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.