Template out the lists of tabs for entities using %ENTITIES and a new template component.
Load LinkAttributeType roots and factor out serialization for edits
MBS-7869: Remove DISTINCT clause from edit search

Current PostgreSQL doesn't cope well with DISTINCT clauses, which are
always taken literally even where they could be optimized away. Remove
the DISTINCT clause in the edit search queries by turning all joins
into semijoins (WHERE EXISTS clauses), which don't generate duplicate
rows to begin with.
MBS-7750: Mark videos "(video)" instead of "(true)"

around$html tried to pass the "video" string to the html method, where
it was overwritten by the boolean value from the entity itself, via
extend. Use a different name (videoString) instead.
Fix rockinchina matching/cleanup, make Last.fm ones look for .com.xx before .com
Show a warning if the CAA appears to be down
MBS-7886: don't allow ratings to be included for places
MBS-7875: Attributes aren't cleared when relationship target type is changed
Update edit search tests
Don't import the switch feature where it isn't used
MBS-7869: Replace DISTINCT clause in edit queries

See previous commit for the case against DISTINCT. One query didn't
even use it, which meant that it could return duplicate edits.
Inline a subquery instead of running it separately
Add limit clause for subscribed-entity edits queries

Normally, queries for edits (by an editor, for a certain entity, etc.)
have a limit of 500 (for the count of edits; the actual number of
edits to be displayed per page is lower). The queries for open edits
by a user's subscribed entities or editors did not, so this adds a
limit, to improve performance when there are more than 500 of them.
Move guess_search for entities to the template

The guess_search flag (indicating that the number of edits returned by
a query may be approximate only) was set from the controller role for
core entities' edit histories, whereas in all other cases it was set
from the template. Change this to always be set from the template.

This also fixes a bug where the list of edits for a collection was
missing the flag, because it uses the same template but is run from a
different controller.
Factor out the limit on edit queries into a constant
MBS-7869: Order edit listings by id instead of open_time

Some queries for edit listings ordered the edits by id, others by
open_time, still others first by open_time then by id. Change this to
always id, as the two columns have almost the same ordering and
sorting by id can more often use indexes instead of an explicit sort.
MBS-7869: Use range query for "on date" edit search

Searching for edits opened/expired/closed on a certain date was done
by truncating the timestamp to day precision, which required special
indexes that aren't useful for anything else. Instead use a range
query (between start of the day and end of the day).
MBS-7869: Improve indexes on edit and vote tables

Improve the indexes on the edit and vote tables:
- Extend some of the existing indexes on edit to also include the id
  column, and the index on vote (editor) to also include the edit
  column, so that matching rows can be retrieved in sorted order.
  This simplifies some query plans, allows using merge joins
  sometimes, and may also enable index-only scans when Postgres is
  updated to 9.2.
- Add indexes on edit (editor, open_time) and vote (editor, vote_time)
  to speed up counting the most recent edits/votes for the user
  profile page.
- Replace the indexes on truncated-to-day open/close/expire time with
  indexes on the time columns directly, so that they can be used for
  arbitrary range queries instead of just the old "on date" query.
- Fix the name of one index on vote.

The two update scripts are intended to be run when the query changes
from the previous commits (sorting by id instead of open_time, mostly)
are released to beta and master, respectively.
Show editing history links for Various Artists

The links to the editing history and the open edits in the sidebar
used to be hidden for Various Artists. The recent query performance
improvements (MBS-7869) reduce the time to get the open edits to
about 1/80 of what it was, and the access time for the complete
editing history was already acceptable, so the links can safely be
shown now.
Show disambiguation comments in area search (MBS-7893)