<commit_before>
# Copyright 2010-2014 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Oghma = @Oghma ?= {}
Oghma.SubMenu ?= {}

# Visibility sub menu.
#
# This is a dynamic menu so the items should be called and added on menu
# display.
#
# @param [Oghma.App] O App.
# @param [Oghma.Thingy] thingy Thingy to set visiblity o.f
# @param [string] key Visible to key.  Default: 'visible_to'.
# @return [Array<Object>] Menu items to add.
#
# @author <NAME> (<EMAIL>)
# @copyright 2013 <NAME>
Oghma.SubMenu.visibility = ( O, thingy, key = 'visible_to' ) ->
  value = thingy.gets( key )
  items = []
  set = ( value ) ->
    attrs = {}
    attrs[ key ] = value
    thingy.set( attrs )

  if value.length == 0
    items.push(
      text: 'Make private'
      handler: -> set( [ O.me().gets('name') ] )
    )
  else
    items.push(
      text: 'Make public.'
      handler: -> set( [] )
    )

  O.allverse.user.each_name( ( name ) ->
    items.push(
      text: name
      checked: value.indexOf( name ) != -1
      handler: ->
        i = value.indexOf( name )
        if i != -1
          value.splice( i, 1 )
        else
          value.push( name )
        set( value )
    )
  )

  items



<commit_msg>submenu/visibility: Now uses users submenu.<commit_after>
# Copyright 2010-2014 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Oghma = @Oghma ?= {}
Oghma.SubMenu ?= {}

# Visibility sub menu.
#
# This is a dynamic menu so the items should be called and added on menu
# display.
#
# @param [Oghma.App] O App.
# @param [Oghma.Thingy] thingy Thingy to set visiblity o.f
# @param [string] key Visible to key.  Default: 'visible_to'.
# @return [Array<Object>] Menu items to add.
#
# @author <NAME> (<EMAIL>)
# @copyright 2013 <NAME>
Oghma.SubMenu.visibility = ( O, thingy, key = 'visible_to' ) ->
  value = thingy.gets( key )
  items = []
  set = ( value ) ->
    attrs = {}
    attrs[ key ] = value
    thingy.set( attrs )

  if value.length == 0
    items.push(
      text: 'Make private'
      handler: -> set( [ O.me().gets('name') ] )
    )
  else
    items.push(
      text: 'Make public.'
      handler: -> set( [] )
    )

  items.push(
    text: 'Visible to'
    menu: Oghma.SubMenu.users( O, 'multi', value,
      ( name, checked ) ->
        if checked
          value.push( name )
        else
          value.splice( value.indexOf( name ), 1 )
        set( value )
    )
  )

  items




{'fraction_non_alphanumeric': 0.1234966265767087, 'fraction_numerical': 0.011146963919037842, 'mean_word_length': 2.6706135629709364, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3286221', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1086, 'n_words': 392}