see comment for multi_toggle_spam
490922
def multi_toggle_deleted threads
    undos = threads.map { |t| actually_toggle_deleted t }
    UndoManager.register "deleting/undeleting #{threads.size.pluralize 'thread'}",
                         undos, lambda { regen_text }, lambda { threads.each { |t| Index.save_thread t } }
    regen_text
    threads.each { |t| Index.save_thread t }
  end
1318048
def comment_sent(comment)
      users = ::User.all.select {|user| user.is_admin? || user.can_review?}
      bcc = users.map {|user| user.email}
      @comment = comment
      @who_name = comment.user.profile.name
      mail bcc: bcc, subject: 'CFP MagmaConf - New comment'
    end
1191845
private void checkJsDocInBlockComments(String fileName) {
    if (!compiler.getOptions().preservesDetailedSourceInfo()) {
      // Comments only available if preservesDetailedSourceInfo is true.
      return;
    }

    for (Comment comment : compiler.getComments(fileName)) {
      if (comment.type == Comment.Type.BLOCK) {
        if (COMMENT_PATTERN.matcher(comment.value).find()) {
          compiler.report(
              JSError.make(
                  fileName,
                  comment.location.start.line + 1,
                  comment.location.start.column,
                  JSDOC_IN_BLOCK_COMMENT));
        }
      }
    }
  }
1277114
function CommentFilter() {
        this.rules = [];
        this.modifiers = [];
        this.allowUnknownTypes = true;
        this.allowTypes = {
            '1': true,
            '2': true,
            '4': true,
            '5': true,
            '6': true,
            '7': true,
            '8': true,
            '17': true
        };
    }
178787
def action_cancel(self):
        """"""
        self.write({'state': 'cancelled'})
        for rec in self:
            rec.message_post(
                subtype='mt_comment',
                body=_(
                    'Change request <b>%s</b> has been cancelled by %s.'
                    ) % (rec.display_name, self.env.user.name)
                )
419296
def check_spam(self, ip=None, email=None, name=None, login=None, realname=None,
                   subject=None, body=None, subject_type='plain', body_type='plain'):
        
        data = {'ip': ip, 'email': email, 'name': name, 'login': login, 'realname': realname,
                'body-%s' % body_type: body, 'subject-%s' % subject_type: subject}
        r = self.request('post', 'http://cleanweb-api.yandex.ru/1.0/check-spam', data=data)
        root = ET.fromstring(r.content)
        return {
            'id': root.findtext('id'),
            'spam_flag': yesnobool(root.find('text').attrib['spam-flag']),
            'links': [(link.attrib['href'], yesnobool(link.attrib['spam-flag'])) for link in root.findall('./links/link')]
        }
403865
def toggle_comment(self):
        
        current_index = self.nav.absolute_index
        self.content.toggle(current_index)

        # This logic handles a display edge case after a comment toggle. We
        # want to make sure that when we re-draw the page, the cursor stays at
        # its current absolute position on the screen. In order to do this,
        # apply a fixed offset if, while inverted, we either try to hide the
        # bottom comment or toggle any of the middle comments.
        if self.nav.inverted:
            data = self.content.get(current_index)
            if data['hidden'] or self.nav.cursor_index != 0:
                window = self._subwindows[-1][0]
                n_rows, _ = window.getmaxyx()
                self.nav.flip(len(self._subwindows) - 1)
                self.nav.top_item_height = n_rows
262100
def send_comment_posted(comment, request):
    
    recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
    site = get_current_site(request)
    content_object = comment.content_object
    content_title = force_text(content_object)

    if comment.is_removed:
        subject = u'[{0}] Spam comment on "{1}"'.format(site.name, content_title)
    elif not comment.is_public:
        subject = u'[{0}] Moderated comment on "{1}"'.format(site.name, content_title)
    else:
        subject = u'[{0}] New comment posted on "{1}"'.format(site.name, content_title)

    context = {
        'site': site,
        'comment': comment,
        'content_object': content_object
    }

    message = render_to_string("comments/comment_notification_email.txt", context, request=request)
    if appsettings.FLUENT_COMMENTS_MULTIPART_EMAILS:
        html_message = render_to_string("comments/comment_notification_email.html", context, request=request)
    else:
        html_message = None

    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
              recipient_list, fail_silently=True, html_message=html_message)
781593
def spam(self, tag=None, fromdate=None, todate=None):
        
        return self.call("GET", "/stats/outbound/spam", tag=tag, fromdate=fromdate, todate=todate)
860444
def _pop_comment(self, statements, comment_re):
        
        res = []
        match = None
        for st in statements:
            if match or not isinstance(st, ast.Comment):
                res.append(st)
                continue
            match = comment_re.match(st.text)
            if not match:
                res.append(st)
        return match, res
422403
def add_automatic_comment(self, ref):
        
        if self.fixed is True:
            text = (DOWNTIME_FIXED_MESSAGE % (ref.my_type,
                                              time.strftime("%Y-%m-%d %H:%M:%S",
                                                            time.localtime(self.start_time)),
                                              time.strftime("%Y-%m-%d %H:%M:%S",
                                                            time.localtime(self.end_time)),
                                              ref.my_type))
        else:
            hours, remainder = divmod(self.duration, 3600)
            minutes, _ = divmod(remainder, 60)
            text = (DOWNTIME_FLEXIBLE_MESSAGE % (ref.my_type,
                                                 time.strftime("%Y-%m-%d %H:%M:%S",
                                                               time.localtime(self.start_time)),
                                                 time.strftime("%Y-%m-%d %H:%M:%S",
                                                               time.localtime(self.end_time)),
                                                 hours, minutes, ref.my_type))

        data = {
            'comment': text,
            'comment_type': 1 if ref.my_type == 'host' else 2,
            'entry_type': 2,
            'source': 0,
            'expires': False,
            'ref': ref.uuid
        }
        comment = Comment(data)
        self.comment_id = comment.uuid
        ref.comments[comment.uuid] = comment
        return comment
215151
def strip_praw_comment(cls, comment):
        

        data = {}
        data['object'] = comment

        if isinstance(comment, praw.objects.MoreComments):
            data['type'] = 'MoreComments'
            data['level'] = comment.nested_level
            data['count'] = comment.count
            data['body'] = 'More comments'
            data['hidden'] = True

        elif hasattr(comment, 'nested_level'):
            author = getattr(comment, 'author', '[deleted]')
            name = getattr(author, 'name', '[deleted]')
            sub = getattr(comment, 'submission', '[deleted]')
            sub_author = getattr(sub, 'author', '[deleted]')
            sub_name = getattr(sub_author, 'name', '[deleted]')
            flair = getattr(comment, 'author_flair_text', '')
            permalink = getattr(comment, 'permalink', None)
            stickied = getattr(comment, 'stickied', False)

            data['type'] = 'Comment'
            data['level'] = comment.nested_level
            data['body'] = comment.body
            data['html'] = comment.body_html
            data['created'] = cls.humanize_timestamp(comment.created_utc)
            data['score'] = '{0} pts'.format(
                '-' if comment.score_hidden else comment.score)
            data['author'] = name
            data['is_author'] = (name == sub_name)
            data['flair'] = flair
            data['likes'] = comment.likes
            data['gold'] = comment.gilded
            data['permalink'] = permalink
            data['stickied'] = stickied
            data['hidden'] = False
            data['saved'] = comment.saved
            if comment.edited:
                data['edited'] = '(edit {})'.format(
                    cls.humanize_timestamp(comment.edited))
            else:
                data['edited'] = ''
        else:
            # Saved comments don't have a nested level and are missing a couple
            # of fields like ``submission``. As a result, we can only load a
            # subset of fields to avoid triggering a separate api call to load
            # the full comment.
            author = getattr(comment, 'author', '[deleted]')
            stickied = getattr(comment, 'stickied', False)
            flair = getattr(comment, 'author_flair_text', '')

            data['type'] = 'SavedComment'
            data['level'] = None
            data['title'] = '[Comment] {0}'.format(comment.body)
            data['comments'] = None
            data['url_full'] = comment._fast_permalink
            data['url'] = comment._fast_permalink
            data['permalink'] = comment._fast_permalink
            data['nsfw'] = comment.over_18
            data['subreddit'] = six.text_type(comment.subreddit)
            data['url_type'] = 'selfpost'
            data['score'] = '{0} pts'.format(
                '-' if comment.score_hidden else comment.score)
            data['likes'] = comment.likes
            data['created'] = cls.humanize_timestamp(comment.created_utc)
            data['saved'] = comment.saved
            data['stickied'] = stickied
            data['gold'] = comment.gilded
            data['author'] = author
            data['flair'] = flair
            data['hidden'] = False
            if comment.edited:
                data['edited'] = '(edit {})'.format(
                    cls.humanize_timestamp(comment.edited))
            else:
                data['edited'] = ''

        return data
891150
def comments_error_display(content = nil)

      html = ''

      if content.errors.any?
        html = "<div id='error-explanation'>
  			<h2>Invalid:</h2><ul>"
        content.errors.full_messages.each do |msg|
          html += "<li>#{msg}</li>"
        end
        html += "</ul>
  			</div>"
      end

      html
    end
99692
def lock_online(self, comment=None):
        
        self.make_request(
            NodeCommandFailed,
            method='update',
            resource='lock_online',
            params={'comment': comment})
183844
def _fast_permalink(self):
        """"""
        if hasattr(self, 'link_id'):  # from /r or /u comments page
            sid = self.link_id.split('_')[1]
        else:  # from user's /message page
            sid = self.context.split('/')[4]
        return urljoin(self.reddit_session.config['comments'], '{0}/_/{1}'
                       .format(sid, self.id))
472256
function(f) {
        var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,
            fn_text        = this.reflector.getProto()[this.name].toString().replace(STRIP_COMMENTS, '');

        return fn_text.substr(fn_text.indexOf('{') + 1, fn_text.lastIndexOf('}') - 4).replace(/}([^}]*)$/, '$1');
    }
475932
def comments(recid):
    """"""
    from invenio_access.local_config import VIEWRESTRCOLL
    from invenio_access.mailcookie import \
        mail_cookie_create_authorize_action
    from .api import check_user_can_view_comments
    auth_code, auth_msg = check_user_can_view_comments(current_user, recid)
    if auth_code and current_user.is_guest:
        cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {
            'collection': g.collection})
        url_args = {'action': cookie, 'ln': g.ln, 'referer': request.referrer}
        flash(_("Authorization failure"), 'error')
        return redirect(url_for('webaccount.login', **url_args))
    elif auth_code:
        flash(auth_msg, 'error')
        abort(401)

    # FIXME check restricted discussion
    comments = CmtRECORDCOMMENT.query.filter(db.and_(
        CmtRECORDCOMMENT.id_bibrec == recid,
        CmtRECORDCOMMENT.in_reply_to_id_cmtRECORDCOMMENT == 0,
        CmtRECORDCOMMENT.star_score == 0
    )).order_by(CmtRECORDCOMMENT.date_creation).all()
    return render_template('comments/comments.html', comments=comments,
                           option='comments')