Schrift
[thread]762[/thread]

suche erst ab einem bestimmten bereich aktivieren (Seite 5)

Leser: 1


<< |< 1 2 3 4 5 6 >| >> 52 Einträge, 6 Seiten
renee
 2006-06-29 12:41
#8152 #8152
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Du solltest Dir vielleich mal Templating-Systeme wie CPAN:HTML::Template, CPAN:HTML::Template::Compiled oder CPAN:Template::Toolkit anschauen. Dann musst Du nicht mehr so umständlich das HTML aufbauen...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Rocco
 2006-06-29 13:40
#8153 #8153
User since
2005-11-18
37 Artikel
BenutzerIn
[default_avatar]
ja super funktioniert tadellos, einzig bei den links gibts noch ein kleines problem, dann is es perfekt.

EDIT: zu sehen wieder unter - http://www.lottermoser.at/test/searchtest.htm\n\n

<!--EDIT|Rocco|1151574047-->
renee
 2006-06-29 13:48
#8154 #8154
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ups, aus:
Code: (dl )
-type => 'text/plain'
muss natürlich
Code: (dl )
-type => 'text/html'
werden...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
renee
 2006-06-29 13:52
#8155 #8155
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Das sollte es sein:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/perl

use CGI::Carp qw(fatalsToBrowser);
use strict;
use warnings;
use CGI;
use File::Find;
use HTML::Parser;

my $cgi = CGI->new();
print $cgi->header(-type => 'text/html');
my %params = $cgi->Vars();
my $string = '';
my $title = '';
my $basedir = '/home/netzgrafik/www.lottermoser.at/test/';
my $base_url = 'http://www.lottermoser.at/';
my $hp_title = 'Alu - Lottermoser';

# hier noch den Pfad zur Vorlage eintragen
my $template = '';

my @files = ();
find(\&find_files,$basedir);
my ($includes) = search($params{terms},\@files,$basedir);
print_html($base_url,$template,$hp_title,$params{terms},$includes);

sub find_files{
push(@files,$File::Find::name) if(-f $File::Find::name && $_ =~ /\.htm$/);
}

sub print_found{
my ($base,$template,$title,$terms,$hashref) = @_;

my $content = '';
{
local $/;
open(my $fh,'<',$template) or die $!;
$content = <$fh>;
close $fh;
}

my $html = '<ul>';
for my $key(keys(%$hashref)){
$html .= '<li><a href="'.$base.$key.'">'.$hashref->{$key}."</li>\n";
}
$html .= qq~</ul><hr align="left" width="100%" size="2" noshade color="#00007F">\n
<font color="#00007F">Such Information:</font><p>
<ul>\n<li><b><FONT COLOR=#00007F>Suchbegriff:</FONT></b>~;

$html.= join(", ",split(/\s+/,$terms));

$html .= qq~<li><a href="$base">$title</a>\n</ul>
<hr align="left" width="100%" size="2" noshade color="#00007F">
<a href="http://www.netzgrafik.com/">netzgrafik.com</a>.\n~;

$content =~ s/\$Titel/$title/;
$content =~ s/\$Message/$html/;

print $content;
}

sub search{
my ($termsstring,$files,$basedir) = @_;
my @terms = split(/\s+/,$termsstring);

my $parser = HTML::Parser->new(
api_version => 3,
start_h => [\&start,"self,tagname,attr"],
text_h => [\&text,"self,dtext"],
end_h => [\&end,"self,tagname"]);

$parser->{divs} = 0;

my %include;
for my $html_file(@$files){
$string = '';
$title = '';
$parser->parse_file($html_file);

foreach my $term (@terms) {
$term = umlauts($term);

# hier wurde noch das "i" angefügt für "ignore case" also
# matching ohne Berücksichtigung von Groß- und Kleinschreibung

if ($string =~ /$term/i) {
(my $local_file = $html_file) =~ s/\Q$basedir\E//;
$include{$html_file} = $title;
last;
}
}
}
return \%include;
}

sub start{
my ($self,$tag,$attr) = @_;
if($tag eq 'div' && $attr->{class} eq 'scroll'){
$self->{search} = 1;
}
if($tag eq 'div' and $self->{search}){
$self->{divs}++;
}
if($tag eq 'title'){
$self->{title} = 1;
}
}

sub text{
my ($self,$dtext) = @_;
$string .= $dtext if($self->{search});
$title = $dtext if($self->{title});
}

sub end{
my ($self,$tag) = @_;
if($tag eq 'div' and $self->{search}){
$self->{divs}--;
}
if($self->{divs} == 0){
$self->{search} = 0;
}
if($tag eq 'title'){
$self->{title} = 0;
}
}

sub umlauts{
my ($term) = @_;
$term=~ s/&”/ä\;/g;
$term=~ s/¾/Ä\;/g;
$term=~ s/&–/ö\;/g;
$term=~ s/÷/Ö\;/g;
$term=~ s/&¸/ü\;/g;
$term=~ s/Ð/Ü\;/g;
$term=~ s/þ/ß\;/g;
return $term;
}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Rocco
 2006-06-29 14:04
#8156 #8156
User since
2005-11-18
37 Artikel
BenutzerIn
[default_avatar]
ja wie gesagt bei den links gibts noch ein problem, versuch mal lottermoser oder pumpe und klick dann auf die generierten links da kommt dann sowas ähnliches heraus - http://www.lottermoser.at/....akt.htm
liegt wohl an ><a href="'.$base.$key.'">

2 kleine fehler hab ich selber ausgebessert und zwar die funktion auf print_html umbenannt und den <a> tag geschlossen
renee
 2006-06-29 14:10
#8157 #8157
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
aus
Code: (dl )
1
2
3
4
5
           if ($string =~ /$term/i) {
(my $local_file = $html_file) =~ s/\Q$basedir\E//;
$include{$html_file} = $title;
last;
}


muss
Code: (dl )
1
2
3
4
5
           if ($string =~ /$term/i) {
(my $local_file = $html_file) =~ s/\Q$basedir\E//;
$include{$local_file} = $title;
last;
}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Rocco
 2006-06-29 14:23
#8158 #8158
User since
2005-11-18
37 Artikel
BenutzerIn
[default_avatar]
joo super jetzt passts perfekt :)
Rocco
 2006-07-01 16:30
#8159 #8159
User since
2005-11-18
37 Artikel
BenutzerIn
[default_avatar]
einen wunsch hätt ich noch:
es wäre schön wenn die suche auch noch die seitentitel miteinbeziehen würde, die titel sind doch auch noch sehr wichtig bei der suche. :)
esskar
 2006-07-01 16:49
#8160 #8160
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
dann zeig doch mal deinen ansatz zu dem problem!
Rocco
 2006-07-01 17:06
#8161 #8161
User since
2005-11-18
37 Artikel
BenutzerIn
[default_avatar]
mein ansatz wäre der,
wenn der titel gefunden wurde, durchsuch ihn gleich mit.

Code: (dl )
1
2
3
4
if($tag eq 'title'){
     $self->{title} = 1;
     $tag->{search} = 1;
 }


funktioniert aber leider nicht :-(
hab noch versucht mit $this, aber ich hab einfach zu wenig durchblick bei der perl syntax.\n\n

<!--EDIT|Rocco|1151760877-->
<< |< 1 2 3 4 5 6 >| >> 52 Einträge, 6 Seiten



View all threads created 2006-06-23 16:05.