File: description_from_body.rb

package info (click to toggle)
tdiary-contrib 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,772 kB
  • sloc: ruby: 17,305; javascript: 8,263; lisp: 562; xml: 451; php: 61; sql: 40; makefile: 18
file content (23 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# description_from_body.rb - set meta description by first section's body in day mode
#
# Copyright (C) 2011, TADA Tadashi <t@tdtds.jp>
# You can redistribute it and/or modify it under GPL.
#

alias description_tag_dfb_orig description_tag
def description_tag
	if @mode == 'day' then
		diary = @diaries[@date.strftime '%Y%m%d']
		return '' unless diary

		body = ''
		diary.each_section do |sec|
			body = remove_tag( apply_plugin( sec.body_to_html ) ).strip
			break
		end
		%Q|<meta name="description" content="#{@conf.shorten body, 256}">|
	else
		description_tag_dfb_orig
	end
end