<commit_before>%% ===================================================================
%% @author <NAME>
%% @copyright (C): 2013 ACK CYFRONET AGH
%% This software is released under the MIT license 
%% cited in 'LICENSE.txt'.
%% @end
%% ===================================================================
%% @doc: This module implements worker_plugin_behaviour callbacks.
%% It is responsible for setting up a nitrogen website, running on cowboy server.
%% @end
%% ===================================================================

-module(control_panel).
-behaviour(worker_plugin_behaviour).

%% ====================================================================
%% API functions
%% ====================================================================
-export([init/1, handle/2, cleanup/0]).

%% ===================================================================
%% Behaviour callback functions
%% ===================================================================

%% init/1
%% ====================================================================
%% @doc {@link worker_plugin_behaviour} callback init/1 <br />
%% Starts required applications (nprocreg and cowboy), sets up
%% cowboy dispatch with nitrogen handler and finally starts
%% cowboy service on desired port.
%% @end
-spec init(Args :: term()) -> Result when
  Result :: ok | {error, Error},
  Error :: term().
%% ====================================================================
init(_Args) ->
  Port = 8000,
  DocRoot = "./gui_static",
  StaticPaths = ["js/","images/","css/","nitrogen/","templates/"],

  Dispatch = init_dispatch(DocRoot, StaticPaths),

  %% Start the listener
  {ok, _} = cowboy:start_http(http, 100, [{port, Port}], [
    {env, [{dispatch, Dispatch}]},
    {max_keepalive, 50}
  ]),

  {ok, { {one_for_one, 5, 10}, []} }.



%% handle/1
%% ====================================================================
%% @doc {@link worker_plugin_behaviour} callback handle/1
-spec handle(ProtocolVersion :: term(), Request) -> Result when
  Request :: ping | get_version,
  Result :: ok | {ok, Response} | {error, Error} | pong | Version,
  Response :: term(),
  Version :: term(),
  Error :: term().
%% ====================================================================
handle(_ProtocolVersion, ping) ->
  pong;

handle(_ProtocolVersion, get_version) ->
  1;<commit_msg>VFS-49: Zmiana return value w control_panel:init/1<commit_after>%% ===================================================================
%% @author <NAME>
%% @copyright (C): 2013 ACK CYFRONET AGH
%% This software is released under the MIT license 
%% cited in 'LICENSE.txt'.
%% @end
%% ===================================================================
%% @doc: This module implements worker_plugin_behaviour callbacks.
%% It is responsible for setting up a nitrogen website, running on cowboy server.
%% @end
%% ===================================================================

-module(control_panel).
-behaviour(worker_plugin_behaviour).

%% ====================================================================
%% API functions
%% ====================================================================
-export([init/1, handle/2, cleanup/0]).

%% ===================================================================
%% Behaviour callback functions
%% ===================================================================

%% init/1
%% ====================================================================
%% @doc {@link worker_plugin_behaviour} callback init/1 <br />
%% Starts required applications (nprocreg and cowboy), sets up
%% cowboy dispatch with nitrogen handler and finally starts
%% cowboy service on desired port.
%% @end
-spec init(Args :: term()) -> Result when
  Result :: ok | {error, Error},
  Error :: term().
%% ====================================================================
init(_Args) ->
  Port = 8000,
  DocRoot = "./gui_static",
  StaticPaths = ["js/","images/","css/","nitrogen/","templates/"],

  Dispatch = init_dispatch(DocRoot, StaticPaths),

  %% Start the listener
  {ok, _} = cowboy:start_http(http, 100, [{port, Port}], [
    {env, [{dispatch, Dispatch}]},
    {max_keepalive, 50}
  ]),

  ok.



%% handle/1
%% ====================================================================
%% @doc {@link worker_plugin_behaviour} callback handle/1
-spec handle(ProtocolVersion :: term(), Request) -> Result when
  Request :: ping | get_version,
  Result :: ok | {ok, Response} | {error, Error} | pong | Version,
  Response :: term(),
  Version :: term(),
  Error :: term().
%% ====================================================================
handle(_ProtocolVersion, ping) ->
  pong;

handle(_ProtocolVersion, get_version) ->
  1;
{'fraction_non_alphanumeric': 0.43138918345705196, 'fraction_numerical': 0.010180275715800637, 'mean_word_length': 6.485714285714286, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6606912', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1075, 'n_words': 307}