From 9795535fe47a986f8be3addc29d9f1676de0fb25 Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Wed, 30 Jul 2014 14:27:48 +0400 Subject: [PATCH] Nodename --- II/Config.pm | 2 ++ II/Render.pm | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/II/Config.pm b/II/Config.pm index 6d734af..dfad5d0 100644 --- a/II/Config.pm +++ b/II/Config.pm @@ -22,12 +22,14 @@ sub load { my $nick = $config->{auth}->{nick}; my $host = $config->{node}->{host}; my @echoareas = split /,/, $config->{node}->{echoareas}; + my $name = $config->{node}->{name}; $c = { nick => $nick, key => $key, host => $host, echoareas => [@echoareas], + name => $name, }; return $c; diff --git a/II/Render.pm b/II/Render.pm index d970cdf..7e5666c 100644 --- a/II/Render.pm +++ b/II/Render.pm @@ -10,10 +10,13 @@ sub new { my $db = II::DB->new(); my $t = II::T->new(); + my $c = II::Config->new(); + my $config = $c->load(); my $self = { _db => $db, _template => $t, + _config => $config, }; bless $self, $class; @@ -24,11 +27,12 @@ sub thread { my ( $self, $subg, $echo ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; my @post = $db->thread( $subg, $echo ); # Render header - my $render = $t->head("ii :: $echo"); + my $render = $t->head("ii ". $config->{name} ." :: $echo"); my $count = 0; while ( $count < @post ) { $render .= $t->post( @post[$count] ); @@ -44,12 +48,13 @@ sub out { my ($self) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; my @post = $db->select_out(); # Render header my $render - = $t->head('ii :: неотправленные сообщения'); + = $t->head('ii '. $config->{name} .' :: неотправленные сообщения'); my $count = 0; while ( $count < @post ) { @@ -66,11 +71,12 @@ sub echo_mes { my ( $self, $echo, $view ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; my @post = $db->echoes($echo); # Render header - my $render = $t->head("ii :: $echo"); + my $render = $t->head("ii ". $config->{name} ." :: $echo"); $render .= $t->echo($echo); my $count = 0; @@ -101,12 +107,13 @@ sub to_me { my ( $self, $config ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; my @post = $db->to_me($config); my @post_from_me = $db->from_me($config); # Render header - my $render = $t->head('ii :: Моя переписка'); + my $render = $t->head('ii '. $config->{name} .' :: Моя переписка'); my $count = 0; while ( $count < @post ) { @@ -136,7 +143,7 @@ sub index { my @hashes = $db->select_index(50); # Render header - my $render = $t->head('ii :: Лента'); + my $render = $t->head('ii '. $config->{name} .' :: Лента'); $render .= $t->index($echoareas); while (<@hashes>) { @@ -156,10 +163,11 @@ sub user { my ( $self, $user ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; # Render header my $render - = $t->head("ii :: Сообщения пользователя $user"); + = $t->head("ii ". $config->{name} ." :: Сообщения пользователя $user"); my @post = $db->select_user($user); @@ -178,8 +186,9 @@ sub user { sub send_new { my ( $self, $echo ) = @_; my $t = $self->{_template}; + my $config = $self->{_config}; - my $render = $t->head("ii :: Новое сообщение"); + my $render = $t->head("ii ". $config->{name} ." :: Новое сообщение"); $render .= $t->new_mes($echo); $render .= $t->foot(); @@ -192,8 +201,9 @@ sub send { my ( $self, $hash ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; - my $render = $t->head("ii :: Ответ на $hash"); + my $render = $t->head("ii". $config->{name} ." :: Ответ на $hash"); # Render post my $data = $db->select_new($hash); @@ -209,8 +219,9 @@ sub new_mes { my ( $self, $msgs ) = @_; my $db = $self->{_db}; my $t = $self->{_template}; + my $config = $self->{_config}; - my $render = $t->head('ii :: Новые сообщения'); + my $render = $t->head('ii '. $config->{name} .' :: Новые сообщения'); # Render posts if ( defined($msgs) ) {