<commit_before>resource = require 'express-resource'
resourceJuggling = require 'resource-juggling'
{rdfmapper} = require 'nodext-create'

exports.registerRoutes = (server, prefix, models, schema) ->
  registerBlog = (blog) ->  
    blog_resource = server.resource resourceJuggling.getResource
      schema: schema
      model: models.Post
      name: 'Post'
      urlName: 'post'
      collection: -> blog.posts
      seek: (request, constraints, callback) ->
        constraints.blogId = blog.id
        models.Post.all
          where: constraints
          order: 'id DESC'
        , callback
      toJSON: rdfmapper.toJSONLD
      addPlaceholderForEmpty: true
  
    blog_resource.map 'get', 'workflow', (req, res) ->
      results = []
      if req.post.published is 'true'
        results.push
          name: 'unpublish'
          label: 'Unpublish'
          action:
            type: 'http'
            http:<commit_msg>Just use the collection<commit_after>resource = require 'express-resource'
resourceJuggling = require 'resource-juggling'
{rdfmapper} = require 'nodext-create'

exports.registerRoutes = (server, prefix, models, schema) ->
  registerBlog = (blog) ->  
    blog_resource = server.resource resourceJuggling.getResource
      schema: schema
      model: models.Post
      name: 'Post'
      urlName: 'post'
      collection: -> blog.posts
      toJSON: rdfmapper.toJSONLD
      addPlaceholderForEmpty: true
  
    blog_resource.map 'get', 'workflow', (req, res) ->
      results = []
      if req.post.published is 'true'
        results.push
          name: 'unpublish'
          label: 'Unpublish'
          action:
            type: 'http'
            http:
{'fraction_non_alphanumeric': 0.10616844602609728, 'fraction_numerical': 0.0, 'mean_word_length': 2.3807615230460923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2824243', 'n_tokens_mistral': 495, 'n_tokens_neox': 487, 'n_words': 119}