<commit_before>require './shared'
require './customizations'
require './dock'
require './histogram'
require './permissions'
require './watch_star'
require './browser_hacks' # for access to browser object
require './browser_location' # for loadPage
require './bubblemouth'
require './filter'

default_cluster_name = 'Proposals'

window.Homepage = ReactiveComponent
  displayName: 'Homepage'
  render: ->
    doc = fetch('document')
    subdomain = fetch('/subdomain')

    title = subdomain.app_title || subdomain.name
    if doc.title != title
      doc.title = title
      save doc

    DIV null,

      customization('Homepage')()

      # if customization('tawkspace')
      #   IFRAME 
      #     src: customization('tawkspace')
      #     height: 500
      #     width: CONTENT_WIDTH()


#############
# SimpleHomepage
#
# Two column layout, with proposal name and mini histogram. 
# Divided into clusters. 


window.proposal_editor = (proposal) ->
  editors = (e for e in proposal.roles.editor when e != '*')
  editor = editors.length > 0 and editors[0]

  return editor != '-' and editor


window.sorted_proposals = (cluster) ->
  cluster_key = "cluster/#{cluster.name}"
  show_icon = customization('show_proposer_icon', cluster_key)
  proposal_support = customization("proposal_support")
  cluster.proposals.slice().sort (a,b) ->
    return proposal_support(b) - proposal_support(a)

cluster_styles = ->

  first_column =
    width: HOMEPAGE_WIDTH() * .6 - 50
    display: 'inline-block'
    verticalAlign: 'top'
    position: 'relative'

  secnd_column =
    width: HOMEPAGE_WIDTH() * .4
    display: 'inline-block'
    verticalAlign: 'top'
    marginLeft: 50

  first_header =
    fontSize: 36
    marginBottom: 40
    fontWeight: 600
  _.extend(first_header, first_column)

  secnd_header =
    fontSize: 36
    marginBottom: 45
    fontWeight: 600
    position: 'relative'
    whiteSpace: 'nowrap'
  _.extend(secnd_header, secnd_column)

  [first_column, secnd_column, first_header, secnd_header]

window.SimpleHomepage = ReactiveComponent
  displayName: 'SimpleHomepage'

  render : ->
    subdomain = fetch('/subdomain')
    proposals = fetch('/proposals')
    current_user = fetch('/current_user')

    line_height = '1.8em'

    # make sure that proposals w/o a cluster use the default cluster
    clusters = {}
    for c in proposals.clusters
      if c.name 
        clusters[c.name] = {}
        for own k,v of c
          clusters[c.name][k] = v
      else 
        unnamed = {}
        for own k,v of c 
          unnamed[k] = v 

    if unnamed 
      if clusters[default_cluster_name]
        c = clusters[default_cluster_name]
        c.proposals = c.proposals.concat unnamed.proposals
      else 
        unnamed.name = default_cluster_name
        clusters[default_cluster_name] = unnamed

    clusters = _.values clusters

    DIV
      className: 'simplehomepage'
      style: 
        fontSize: 22
        margin: '45px auto'
        width: HOMEPAGE_WIDTH()
        position: 'relative'

      STYLE null,
        '''a.proposal:hover {border-bottom: 1px solid grey}'''

      if customization('user_filters')
        UserFilter
          style: 
            width: CONTENT_WIDTH()
            marginBottom: 20
            paddingLeft: if customization('show_proposer_icon') then 68


      # List all clusters

      for cluster, index in clusters or []
        cluster_key = "cluster/#{cluster.name}"

        cluster_keys = ['archived', 'label', 'description', 'homie_histo_title', \
                        'show_proposer_icon', 'slider_handle', 'slider_pole_labels', 
                        'slider_regions', 'slider_ticks', 'discussion', 'show_score']
        options = {}
        for k in cluster_keys
          options[k] = customization k, cluster_key 
<commit_msg>move archived clusters to the back<commit_after>require './shared'
require './customizations'
require './dock'
require './histogram'
require './permissions'
require './watch_star'
require './browser_hacks' # for access to browser object
require './browser_location' # for loadPage
require './bubblemouth'
require './filter'

default_cluster_name = 'Proposals'

window.Homepage = ReactiveComponent
  displayName: 'Homepage'
  render: ->
    doc = fetch('document')
    subdomain = fetch('/subdomain')

    title = subdomain.app_title || subdomain.name
    if doc.title != title
      doc.title = title
      save doc

    DIV null,

      customization('Homepage')()

      # if customization('tawkspace')
      #   IFRAME 
      #     src: customization('tawkspace')
      #     height: 500
      #     width: CONTENT_WIDTH()


#############
# SimpleHomepage
#
# Two column layout, with proposal name and mini histogram. 
# Divided into clusters. 


window.proposal_editor = (proposal) ->
  editors = (e for e in proposal.roles.editor when e != '*')
  editor = editors.length > 0 and editors[0]

  return editor != '-' and editor


window.sorted_proposals = (cluster) ->
  cluster_key = "cluster/#{cluster.name}"
  show_icon = customization('show_proposer_icon', cluster_key)
  proposal_support = customization("proposal_support")
  cluster.proposals.slice().sort (a,b) ->
    return proposal_support(b) - proposal_support(a)

cluster_keys = ['archived', 'label', 'description', 'homie_histo_title', \
                'show_proposer_icon', 'slider_handle', 'slider_pole_labels', 
                'slider_regions', 'slider_ticks', 'discussion', 'show_score']

cluster_options = (key) -> 
  options = {}
  for k in cluster_keys
    options[k] = customization k, key 
  options


cluster_styles = ->

  first_column =
    width: HOMEPAGE_WIDTH() * .6 - 50
    display: 'inline-block'
    verticalAlign: 'top'
    position: 'relative'

  secnd_column =
    width: HOMEPAGE_WIDTH() * .4
    display: 'inline-block'
    verticalAlign: 'top'
    marginLeft: 50

  first_header =
    fontSize: 36
    marginBottom: 40
    fontWeight: 600
  _.extend(first_header, first_column)

  secnd_header =
    fontSize: 36
    marginBottom: 45
    fontWeight: 600
    position: 'relative'
    whiteSpace: 'nowrap'
  _.extend(secnd_header, secnd_column)

  [first_column, secnd_column, first_header, secnd_header]

window.SimpleHomepage = ReactiveComponent
  displayName: 'SimpleHomepage'

  render : ->
    subdomain = fetch('/subdomain')
    proposals = fetch('/proposals')
    current_user = fetch('/current_user')

    line_height = '1.8em'

    # make sure that proposals w/o a cluster use the default cluster
    clusters = {}
    for c in proposals.clusters
      if c.name 
        clusters[c.name] = {}
        for own k,v of c
          clusters[c.name][k] = v
      else 
        unnamed = {}
        for own k,v of c 
          unnamed[k] = v 

    if unnamed 
      if clusters[default_cluster_name]
        c = clusters[default_cluster_name]
        c.proposals = c.proposals.concat unnamed.proposals
      else 
        unnamed.name = default_cluster_name
        clusters[default_cluster_name] = unnamed


    # move archived clusters to the back 
    clusters = _.values clusters
    c = []
    a = []
    for cluster in clusters 
      if !cluster.archived
        c.push cluster 
      else 
        a.push cluster 
    for cluster in a 
      c.push cluster 
    clusters = c

    DIV
      className: 'simplehomepage'
      style: 
        fontSize: 22
        margin: '45px auto'
        width: HOMEPAGE_WIDTH()
        position: 'relative'

      STYLE null,
        '''a.proposal:hover {border-bottom: 1px solid grey}'''

      if customization('user_filters')
        UserFilter
          style: 
            width: CONTENT_WIDTH()
            marginBottom: 20
            paddingLeft: if customization('show_proposer_icon') then 68


      # List all clusters

      for cluster, index in clusters or []
        cluster_key = "cluster/#{cluster.name}"

        options = cluster_options cluster_key

{'fraction_non_alphanumeric': 0.10834386852085967, 'fraction_numerical': 0.009102402022756004, 'mean_word_length': 2.670997679814385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2722608', 'n_tokens_mistral': 2524, 'n_tokens_neox': 2371, 'n_words': 606}