<commit_before>_ = require 'underscore'
Q = require 'q'
sd = require('sharify').data
Article = require '../../models/article'
Articles = require '../../collections/articles'
Vertical = require '../../models/vertical'
Verticals = require '../../collections/verticals'
embedVideo = require 'embed-video'
{ POST_TO_ARTICLE_SLUGS } = require '../../config'

@articles = (req, res, next) ->
  Q.allSettled([
    (verticals = new Verticals).fetch()
    (articles = new Articles).fetch(
      data:
        published: true
        limit: 50
        sort: '-published_at'
        featured: true
    )
  ]).fail(next).then =>
    res.locals.sd.ARTICLES = articles.toJSON()
    res.locals.sd.ARTICLES_COUNT = articles.count
    vertical = verticals.running()[0]
    res.render 'articles', vertical: vertical, articles: articles

@show = (req, res, next) ->
  new Article(id: req.params.slug).fetchWithRelated
    accessToken: req.user?.get('accessToken')
    error: res.backboneError
    success: (data) ->
      if req.params.slug isnt data.article.get('slug')
        return res.redirect "/article/#{data.article.get 'slug'}"
      res.locals.sd.SLIDESHOW_ARTWORKS = data.slideshowArtworks?.toJSON()
      res.locals.sd.ARTICLE = data.article.toJSON()
      res.locals.sd.FOOTER_ARTICLES = data.footerArticles.toJSON()
      videoOptions = { query: { title: 0, portrait: 0, badge: 0, byline: 0, showinfo: 0, rel: 0, controls: 2, modestbranding: 1, iv_load_policy: 3, color: "E5E5E5" } }
      res.render 'show', _.extend data, embedVideo: embedVideo, videoOptions: videoOptions

@redirectPost = (req, res, next) ->
  res.redirect 301, req.url.replace 'post', 'article'

@vertical = (req, res, next) ->
  new Vertical(id: req.params.slug).fetch
    error: res.backboneError
    success: (vertical) ->
      return next() unless req.params.slug is vertical.get('slug')
      new Articles().fetch
        data:
          published: true
          limit: 100
          sort: '-published_at'<commit_msg>safe why not<commit_after>_ = require 'underscore'
Q = require 'q'
sd = require('sharify').data
Article = require '../../models/article'
Articles = require '../../collections/articles'
Vertical = require '../../models/vertical'
Verticals = require '../../collections/verticals'
embedVideo = require 'embed-video'
{ POST_TO_ARTICLE_SLUGS } = require '../../config'

@articles = (req, res, next) ->
  Q.allSettled([
    (verticals = new Verticals).fetch()
    (articles = new Articles).fetch(
      data:
        published: true
        limit: 50
        sort: '-published_at'
        featured: true
    )
  ]).fail(next).then =>
    res.locals.sd.ARTICLES = articles.toJSON()
    res.locals.sd.ARTICLES_COUNT = articles.count
    vertical = verticals.running()?[0]
    res.render 'articles', vertical: vertical, articles: articles

@show = (req, res, next) ->
  new Article(id: req.params.slug).fetchWithRelated
    accessToken: req.user?.get('accessToken')
    error: res.backboneError
    success: (data) ->
      if req.params.slug isnt data.article.get('slug')
        return res.redirect "/article/#{data.article.get 'slug'}"
      res.locals.sd.SLIDESHOW_ARTWORKS = data.slideshowArtworks?.toJSON()
      res.locals.sd.ARTICLE = data.article.toJSON()
      res.locals.sd.FOOTER_ARTICLES = data.footerArticles.toJSON()
      videoOptions = { query: { title: 0, portrait: 0, badge: 0, byline: 0, showinfo: 0, rel: 0, controls: 2, modestbranding: 1, iv_load_policy: 3, color: "E5E5E5" } }
      res.render 'show', _.extend data, embedVideo: embedVideo, videoOptions: videoOptions

@redirectPost = (req, res, next) ->
  res.redirect 301, req.url.replace 'post', 'article'

@vertical = (req, res, next) ->
  new Vertical(id: req.params.slug).fetch
    error: res.backboneError
    success: (vertical) ->
      return next() unless req.params.slug is vertical.get('slug')
      new Articles().fetch
        data:
          published: true
          limit: 100
          sort: '-published_at'
{'fraction_non_alphanumeric': 0.15150753768844222, 'fraction_numerical': 0.010552763819095477, 'mean_word_length': 3.1168562564632887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4981653', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1292, 'n_words': 303}