old_contents: # -*- coding: utf-8 -*-
  
  import re
  import logging
  import urlparse
  
  from flask import request, url_for
  
  from website import settings
  
  # Keep me: Makes rubeus importable from website.util
  from . import rubeus  # noqa
  
  logger = logging.getLogger(__name__)
  
  
  guid_url_node_pattern = re.compile('^/project/[a-zA-Z0-9]{5,}/node(?=/[a-zA-Z0-9]{5,})')
  guid_url_project_pattern = re.compile('^/project(?=/[a-zA-Z0-9]{5,})')
  guid_url_profile_pattern = re.compile('^/profile(?=/[a-zA-Z0-9]{5,})')
  
  
  def _get_guid_url_for(url):
      """URL Post-processor transforms specific `/project/<pid>` or `/project/<pid>/node/<nid>`
      urls into guid urls. Ex: `<nid>/wiki/home`.
      """
      guid_url = guid_url_node_pattern.sub('', url, count=1)
      guid_url = guid_url_project_pattern.sub('', guid_url, count=1)
      guid_url = guid_url_profile_pattern.sub('', guid_url, count=1)
      return guid_url
  
  
  def api_url_for(view_name, _absolute=False, _xml=False, *args, **kwargs):
      """Reverse URL lookup for API routes (that use the JSONRenderer or XMLRenderer).
      Takes the same arguments as Flask's url_for, with the addition of
      `_absolute`, which will make an absolute URL with the correct HTTP scheme
      based on whether the app is in debug mode, and the adition of the _xml flag that
      will set the renderer to use.
      """
      renderer = 'XMLRenderer' if _xml else 'JSONRenderer'
  
      url = url_for('{0}__{1}'.format(renderer, view_name), *args, **kwargs)
  
      if _absolute:
      #     # We do NOT use the url_for's _external kwarg because app.config['SERVER_NAME'] alters
      #     # behavior in an unknown way (currently breaks tests). /sloria /jspies
          return urlparse.urljoin(settings.DOMAIN, url)
      return url
  
  
  def web_url_for(view_name, _absolute=False, _guid=False, *args, **kwargs):
      """Reverse URL lookup for web routes (those that use the OsfWebRenderer).
      Takes the same arguments as Flask's url_for, with the addition of
      `_absolute`, which will make an absolute URL with the correct HTTP scheme
      based on whether the app is in debug mode.
      """
      url = url_for('OsfWebRenderer__{0}'.format(view_name), *args, **kwargs)
      if _guid:
          url = _get_guid_url_for(url)
  
      if _absolute:
          # We do NOT use the url_for's _external kwarg because app.config['SERVER_NAME'] alters
          # behavior in an unknown way (currently breaks tests). /sloria /jspies
          return urlparse.urljoin(settings.DOMAIN, url)
      return url
  
  
  def is_json_request():
      """Return True if the current request is a JSON/AJAX request."""
      content_type = request.content_type
      return content_type and ('application/json' in content_type)
  
new_contents: # -*- coding: utf-8 -*-
  
  import re
  import logging
  import urlparse
  
  from flask import request, url_for
  
  from website import settings
  
  # Keep me: Makes rubeus importable from website.util
  from . import rubeus  # noqa
  
  logger = logging.getLogger(__name__)
  
  
  guid_url_node_pattern = re.compile('^/project/[a-zA-Z0-9]{5,}/node(?=/[a-zA-Z0-9]{5,})')
  guid_url_project_pattern = re.compile('^/project(?=/[a-zA-Z0-9]{5,})')
  guid_url_profile_pattern = re.compile('^/profile(?=/[a-zA-Z0-9]{5,})')
  
  
  def _get_guid_url_for(url):
      """URL Post-processor transforms specific `/project/<pid>` or `/project/<pid>/node/<nid>`
      urls into guid urls. Ex: `<nid>/wiki/home`.
      """
      guid_url = guid_url_node_pattern.sub('', url, count=1)
      guid_url = guid_url_project_pattern.sub('', guid_url, count=1)
      guid_url = guid_url_profile_pattern.sub('', guid_url, count=1)
      return guid_url
  
  
  def api_url_for(view_name, _absolute=False, _xml=False, *args, **kwargs):
      """Reverse URL lookup for API routes (that use the JSONRenderer or XMLRenderer).
      Takes the same arguments as Flask's url_for, with the addition of
      `_absolute`, which will make an absolute URL with the correct HTTP scheme
      based on whether the app is in debug mode. The _xml flag sets the renderer to use.
      """
      renderer = 'XMLRenderer' if _xml else 'JSONRenderer'
  
      url = url_for('{0}__{1}'.format(renderer, view_name), *args, **kwargs)
  
      if _absolute:
      #     # We do NOT use the url_for's _external kwarg because app.config['SERVER_NAME'] alters
      #     # behavior in an unknown way (currently breaks tests). /sloria /jspies
          return urlparse.urljoin(settings.DOMAIN, url)
      return url
  
  
  def web_url_for(view_name, _absolute=False, _guid=False, *args, **kwargs):
      """Reverse URL lookup for web routes (those that use the OsfWebRenderer).
      Takes the same arguments as Flask's url_for, with the addition of
      `_absolute`, which will make an absolute URL with the correct HTTP scheme
      based on whether the app is in debug mode.
      """
      url = url_for('OsfWebRenderer__{0}'.format(view_name), *args, **kwargs)
      if _guid:
          url = _get_guid_url_for(url)
  
      if _absolute:
          # We do NOT use the url_for's _external kwarg because app.config['SERVER_NAME'] alters
          # behavior in an unknown way (currently breaks tests). /sloria /jspies
          return urlparse.urljoin(settings.DOMAIN, url)
      return url
  
  
  def is_json_request():
      """Return True if the current request is a JSON/AJAX request."""
      content_type = request.content_type
      return content_type and ('application/json' in content_type)
  
subject: update docs for renderer