<commit_before>########################################################
# AngularJS controller file
########################################################

angular.module('feedbunch').controller 'FeedbunchCtrl',
['$rootScope', '$scope', '$timeout', '$sce', 'feedsFoldersSvc', 'importStateSvc', 'exportStateSvc', 'timerFlagSvc',
'currentFeedSvc', 'currentFolderSvc', 'subscriptionSvc', 'readSvc', 'folderSvc', 'entrySvc', 'entriesPaginationSvc',
'findSvc', 'userDataSvc', 'userConfigSvc', 'openEntrySvc', 'unreadCountSvc', 'sidebarVisibleSvc', 'menuCollapseSvc',
'tooltipSvc', 'startPageSvc', 'jobStateSvc', 'socialNetworksSvc',
($rootScope, $scope, $timeout, $sce, feedsFoldersSvc, importStateSvc, exportStateSvc, timerFlagSvc,
currentFeedSvc, currentFolderSvc, subscriptionSvc, readSvc, folderSvc, entrySvc, entriesPaginationSvc,
findSvc, userDataSvc, userConfigSvc, openEntrySvc, unreadCountSvc, sidebarVisibleSvc, menuCollapseSvc,
tooltipSvc, startPageSvc, jobStateSvc, socialNetworksSvc)->

  #--------------------------------------------
  # APPLICATION INITIALIZATION
  #--------------------------------------------

  # By default sidebar is visible in smartphones and other small screens
  sidebarVisibleSvc.set true

  # Show Add Subscription button in this view
  $rootScope.show_feed_buttons = true

  # Initialize navbar tooltips
  tooltipSvc.navbar_tooltips()

  # Initialize footer tooltips
  tooltipSvc.footer_tooltips()

  # Initialize import alert tooltips
  tooltipSvc.import_state_tooltips()

  # Initialize export alert tooltips
  tooltipSvc.export_state_tooltips()

  # Load configuration for the current user.
  userConfigSvc.load_config()

  # Load data for the current user.
  userDataSvc.load_data()

  # Load folders and feeds via AJAX on startup
  feedsFoldersSvc.start_refresh_timer()

  # Load state of data export process for the current user
  exportStateSvc.load_data false

  # Load state of data import process for the current user
  importStateSvc.load_data false

  # Load job states via AJAX on startup
  jobStateSvc.load_data()

  # If there is a rails alert, show it and close it after 5 seconds
  timerFlagSvc.start 'error_rails'

  # Initialize collapsing menu in smartphones
  menuCollapseSvc.start()

  #--------------------------------------------
  # Show the start page
  #--------------------------------------------
  $scope.show_start_page = ->
    startPageSvc.show_start_page()
    return

  #--------------------------------------------
  # Unsubscribe from a feed
  #--------------------------------------------
  $scope.unsubscribe = ->
    subscriptionSvc.unsubscribe()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Subscribe to a feed
  #--------------------------------------------
  $scope.subscribe = ->
    $("#subscribe-feed-popup").modal 'hide'
    subscriptionSvc.subscribe $scope.subscription_url
    $scope.subscription_url = null
    return

  #--------------------------------------------
  # Show all feeds (regardless of whether they have unread entries or not)
  # and all entries (regardless of whether they are read or not).
  #--------------------------------------------
  $scope.show_read_feeds_entries = ->
    feedsFoldersSvc.show_read()
    readSvc.read_entries_page()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Show only unread entries and feeds with unread entries.
  #--------------------------------------------
  $scope.hide_read_feeds_entries = ->
    feedsFoldersSvc.hide_read()
    readSvc.read_entries_page()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Remove a feed from a folder
  #--------------------------------------------
  $scope.remove_from_folder = ->
    folderSvc.remove_from_folder()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Move a feed to an already existing folder
  #--------------------------------------------
  $scope.move_to_folder = (folder)->
    folderSvc.move_to_folder folder
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Move a feed to a new folder
  #--------------------------------------------
  $scope.move_to_new_folder = ()->
    $("#new-folder-popup").modal 'hide'
    folderSvc.move_to_new_folder $scope.new_folder_title
    $scope.new_folder_title = null
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Get the currently selected feed
  #--------------------------------------------
  $scope.get_current_feed = ->
    return currentFeedSvc.get()

  #--------------------------------------------
  # Set the currently selected feed
  #--------------------------------------------
  $scope.set_current_feed = (feed_id)->
    feed = findSvc.find_feed feed_id
    if feed?
      currentFeedSvc.set feed
      tooltipSvc.feed_title_tooltip()
      readSvc.read_entries_page()
      feedsFoldersSvc.load_feed feed_id
      menuCollapseSvc.close()
      sidebarVisibleSvc.set false
    return

  #--------------------------------------------
  # Set the currently selected folder
  #--------------------------------------------
  $scope.set_current_folder = (folder)->
    # If the "all subscriptions" link is not enabled, do nothing.
    if $scope.all_subscriptions_enabled()
      currentFolderSvc.set folder
      readSvc.read_entries_page()
      feedsFoldersSvc.load_folder_feeds folder
      menuCollapseSvc.close()
      sidebarVisibleSvc.set false
    return

  #--------------------------------------------
  # Load a page of entries for the currently selected feed or folder
  #--------------------------------------------
  $scope.read_entries_page = ->
    readSvc.read_entries_page()
    return

  #--------------------------------------------<commit_msg>When clicking on sidebar links, load entries after loading feeds.<commit_after>########################################################
# AngularJS controller file
########################################################

angular.module('feedbunch').controller 'FeedbunchCtrl',
['$rootScope', '$scope', '$timeout', '$sce', 'feedsFoldersSvc', 'importStateSvc', 'exportStateSvc', 'timerFlagSvc',
'currentFeedSvc', 'currentFolderSvc', 'subscriptionSvc', 'readSvc', 'folderSvc', 'entrySvc', 'entriesPaginationSvc',
'findSvc', 'userDataSvc', 'userConfigSvc', 'openEntrySvc', 'unreadCountSvc', 'sidebarVisibleSvc', 'menuCollapseSvc',
'tooltipSvc', 'startPageSvc', 'jobStateSvc', 'socialNetworksSvc',
($rootScope, $scope, $timeout, $sce, feedsFoldersSvc, importStateSvc, exportStateSvc, timerFlagSvc,
currentFeedSvc, currentFolderSvc, subscriptionSvc, readSvc, folderSvc, entrySvc, entriesPaginationSvc,
findSvc, userDataSvc, userConfigSvc, openEntrySvc, unreadCountSvc, sidebarVisibleSvc, menuCollapseSvc,
tooltipSvc, startPageSvc, jobStateSvc, socialNetworksSvc)->

  #--------------------------------------------
  # APPLICATION INITIALIZATION
  #--------------------------------------------

  # By default sidebar is visible in smartphones and other small screens
  sidebarVisibleSvc.set true

  # Show Add Subscription button in this view
  $rootScope.show_feed_buttons = true

  # Initialize navbar tooltips
  tooltipSvc.navbar_tooltips()

  # Initialize footer tooltips
  tooltipSvc.footer_tooltips()

  # Initialize import alert tooltips
  tooltipSvc.import_state_tooltips()

  # Initialize export alert tooltips
  tooltipSvc.export_state_tooltips()

  # Load configuration for the current user.
  userConfigSvc.load_config()

  # Load data for the current user.
  userDataSvc.load_data()

  # Load folders and feeds via AJAX on startup
  feedsFoldersSvc.start_refresh_timer()

  # Load state of data export process for the current user
  exportStateSvc.load_data false

  # Load state of data import process for the current user
  importStateSvc.load_data false

  # Load job states via AJAX on startup
  jobStateSvc.load_data()

  # If there is a rails alert, show it and close it after 5 seconds
  timerFlagSvc.start 'error_rails'

  # Initialize collapsing menu in smartphones
  menuCollapseSvc.start()

  #--------------------------------------------
  # Show the start page
  #--------------------------------------------
  $scope.show_start_page = ->
    startPageSvc.show_start_page()
    return

  #--------------------------------------------
  # Unsubscribe from a feed
  #--------------------------------------------
  $scope.unsubscribe = ->
    subscriptionSvc.unsubscribe()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Subscribe to a feed
  #--------------------------------------------
  $scope.subscribe = ->
    $("#subscribe-feed-popup").modal 'hide'
    subscriptionSvc.subscribe $scope.subscription_url
    $scope.subscription_url = null
    return

  #--------------------------------------------
  # Show all feeds (regardless of whether they have unread entries or not)
  # and all entries (regardless of whether they are read or not).
  #--------------------------------------------
  $scope.show_read_feeds_entries = ->
    feedsFoldersSvc.show_read()
    readSvc.read_entries_page()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Show only unread entries and feeds with unread entries.
  #--------------------------------------------
  $scope.hide_read_feeds_entries = ->
    feedsFoldersSvc.hide_read()
    readSvc.read_entries_page()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Remove a feed from a folder
  #--------------------------------------------
  $scope.remove_from_folder = ->
    folderSvc.remove_from_folder()
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Move a feed to an already existing folder
  #--------------------------------------------
  $scope.move_to_folder = (folder)->
    folderSvc.move_to_folder folder
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Move a feed to a new folder
  #--------------------------------------------
  $scope.move_to_new_folder = ()->
    $("#new-folder-popup").modal 'hide'
    folderSvc.move_to_new_folder $scope.new_folder_title
    $scope.new_folder_title = null
    menuCollapseSvc.close()
    return

  #--------------------------------------------
  # Get the currently selected feed
  #--------------------------------------------
  $scope.get_current_feed = ->
    return currentFeedSvc.get()

  #--------------------------------------------
  # Set the currently selected feed
  #--------------------------------------------
  $scope.set_current_feed = (feed_id)->
    feed = findSvc.find_feed feed_id
    if feed?
      currentFeedSvc.set feed
      tooltipSvc.feed_title_tooltip()
      feedsFoldersSvc.load_feed feed_id
      readSvc.read_entries_page()
      menuCollapseSvc.close()
      sidebarVisibleSvc.set false
    return

  #--------------------------------------------
  # Set the currently selected folder
  #--------------------------------------------
  $scope.set_current_folder = (folder)->
    # If the "all subscriptions" link is not enabled, do nothing.
    if $scope.all_subscriptions_enabled()
      currentFolderSvc.set folder
      feedsFoldersSvc.load_folder_feeds folder
      readSvc.read_entries_page()
      menuCollapseSvc.close()
      sidebarVisibleSvc.set false
    return

  #--------------------------------------------
  # Load a page of entries for the currently selected feed or folder
  #--------------------------------------------
  $scope.read_entries_page = ->
    readSvc.read_entries_page()
    return

  #--------------------------------------------
{'fraction_non_alphanumeric': 0.2902459711620017, 'fraction_numerical': 0.00016963528413910093, 'mean_word_length': 1.7723959557959088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '531893', 'n_tokens_mistral': 3181, 'n_tokens_neox': 3074, 'n_words': 727}