Project

General

Profile

patch02_dirlisting_automatically_use_html.patch

Patch 2: Uses HTML files if they exist, else TXT - penma, 2009-09-06 11:08

View differences:

src/mod_dirlisting.c
519 519

  
520 520
		buffer_copy_string_buffer(p->tmp_buf, con->physical.path);
521 521
		PATHNAME_APPEND_SLASH(p->tmp_buf);
522
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt"));
522
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.html"));
523 523

  
524 524
		if (-1 != stream_open(&s, p->tmp_buf)) {
525
			buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">"));
526
			buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
527
			buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
525
			buffer_append_string_len(out, s.start, s.size);
526
		} else {
527
			stream_close(&s);
528

  
529
			buffer_copy_string_buffer(p->tmp_buf, con->physical.path);
530
			PATHNAME_APPEND_SLASH(p->tmp_buf);
531
			buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt"));
532

  
533
			if (-1 != stream_open(&s, p->tmp_buf)) {
534
				buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">"));
535
				buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
536
				buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
537
			}
528 538
		}
529 539
		stream_close(&s);
530 540
	}
......
564 574

  
565 575
	if (p->conf.show_readme) {
566 576
		stream s;
577

  
567 578
		/* if we have a README file, display it in <pre class="readme"></pre> */
568 579

  
569 580
		buffer_copy_string_buffer(p->tmp_buf,  con->physical.path);
570 581
		PATHNAME_APPEND_SLASH(p->tmp_buf);
571
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt"));
582
		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.html"));
572 583

  
573 584
		if (-1 != stream_open(&s, p->tmp_buf)) {
574
			buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
575
			buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
576
			buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
585
			buffer_append_string_len(out, s.start, s.size);
586
		} else {
587
			stream_close(&s);
588

  
589
			buffer_copy_string_buffer(p->tmp_buf,  con->physical.path);
590
			PATHNAME_APPEND_SLASH(p->tmp_buf);
591
			buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt"));
592

  
593
			if (-1 != stream_open(&s, p->tmp_buf)) {
594
				buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
595
				buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);
596
				buffer_append_string_len(out, CONST_STR_LEN("</pre>"));
597
			}
577 598
		}
578 599
		stream_close(&s);
579 600
	}
......
677 698
		if (p->conf.hide_readme_file) {
678 699
			if (strcmp(dent->d_name, "README.txt") == 0)
679 700
				continue;
701
			if (strcmp(dent->d_name, "README.html") == 0)
702
				continue;
680 703
		}
681 704
		if (p->conf.hide_header_file) {
682 705
			if (strcmp(dent->d_name, "HEADER.txt") == 0)
683 706
				continue;
707
			if (strcmp(dent->d_name, "HEADER.html") == 0)
708
				continue;
684 709
		}
685 710

  
686 711
		/* compare d_name against excludes array