File: tdiary.rb

package info (click to toggle)
tdiary 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,088 kB
  • sloc: ruby: 23,031; javascript: 1,029; xml: 325; makefile: 26; sh: 4
file content (146 lines) | stat: -rw-r--r-- 4,348 bytes parent folder | download
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
139
140
141
142
143
144
145
146
=begin
== NAME
tDiary: the "tsukkomi-able" web diary system.

Copyright (C) 2001-2013, TADA Tadashi <t@tdtds.jp>
You can redistribute it and/or modify it under GPL2 or any later version.
=end

Encoding::default_external = 'UTF-8'

require 'tdiary/version'
TDIARY_VERSION = TDiary::VERSION

$:.unshift File.join(File::dirname(__FILE__), '../misc/lib')
['../misc/lib/*/lib', '../vendor/*/lib'].each do |path|
	Dir[File.join(File.dirname(__FILE__), path)].each {|dir| $:.unshift dir }
end

require 'cgi'
require 'uri'
require 'fileutils'
require 'pstore'
require 'json'
require 'erb'
require 'tdiary/environment'
require 'tdiary/compatible'
require 'tdiary/core_ext'
require 'rack'
require 'rackup'

#
# module TDiary
#
module TDiary
	PATH = File::dirname( __FILE__ )

	# tDiary configuration class, initialize tdiary.conf and stored configuration.
	autoload :Configuration,            'tdiary/configuration'
	autoload :Config,                   'tdiary/configuration'
	# tDiary plugin class, loading all Plugin and eval plugins in view context.
	autoload :Plugin,                   'tdiary/plugin'
	# tDiary Filter class, all filters is loaded by in TDiaryView.
	autoload :Filter,                   'tdiary/filter'

	# CGI standalone server
	autoload :Server,                   'tdiary/server'
	# Rack Application, TODO: integrate Server and Application
	autoload :Application,              'tdiary/application'
	autoload :Extensions,               'tdiary/extensions'

	# Diary model class
	autoload :Style,                    'tdiary/style'
	autoload :Comment,                  'tdiary/comment'
	autoload :DiaryContainer,           'tdiary/diary_container'

	# Routing and Dispatch
	autoload :Dispatcher,               'tdiary/dispatcher'
	# Rack Request and Reponse, If you don't use Rack, adopt Rack interface.
	autoload :Request,                  'tdiary/request'
	autoload :Response,                 'tdiary/response'

	# ViewController created by Dispatcher
	autoload :TDiaryBase,               'tdiary/base'
	autoload :TDiaryCategoryView,       'tdiary/base'
	autoload :TDiarySearch,             'tdiary/base'
	autoload :TDiaryPluginView,         'tdiary/base'
	autoload :TDiaryAuthorOnlyBase,     'tdiary/author_only_base'
	autoload :TDiaryFormPlugin,         'tdiary/author_only_base'
	autoload :TDiaryConf,               'tdiary/author_only_base'
	autoload :TDiarySaveConf,           'tdiary/author_only_base'
	autoload :TDiaryAdmin,              'tdiary/admin'
	autoload :TDiaryForm,               'tdiary/admin'
	autoload :TDiaryEdit,               'tdiary/admin'
	autoload :TDiaryPreview,            'tdiary/admin'
	autoload :TDiaryUpdate,             'tdiary/admin'
	autoload :TDiaryAppend,             'tdiary/admin'
	autoload :TDiaryReplace,            'tdiary/admin'
	autoload :TDiaryShowComment,        'tdiary/admin'
	autoload :TDiaryView,               'tdiary/view'
	autoload :TDiaryDay,                'tdiary/view'
	autoload :TDiaryDayWithoutFilter,   'tdiary/view'
	autoload :TDiaryComment,            'tdiary/view'
	autoload :TDiaryMonthBase,          'tdiary/view'
	autoload :TDiaryMonth,              'tdiary/view'
	autoload :TDiaryNYear,              'tdiary/view'
	autoload :TDiaryMonthWithoutFilter, 'tdiary/view'
	autoload :TDiaryLatest,             'tdiary/view'

	# Helper, these module called from ViewController and Plugins
	autoload :ViewHelper,               'tdiary/view_helper'

	#
	# exception classes
	#
	class TDiaryError < StandardError; end
	class PermissionError < TDiaryError; end
	class PluginError < TDiaryError; end
	class BadStyleError < TDiaryError; end
	class NotFound < TDiaryError;	end

	# class ForceRedirect
	#  force redirect to another page
	#
	class ForceRedirect < StandardError
		attr_reader :path
		def initialize( path )
			@path = path
		end
	end

	class << self
		def logger
			@@logger
		end

		def logger=(obj)
			@@logger = obj
		end

		def root
			File.expand_path(File.join(library_root, '..'))
		end

		# directory where tDiary libraries is located
		def library_root
			File.expand_path('..', __FILE__)
		end

		# directory where the server was started
		def server_root
			Dir.pwd
		end

		def configuration
			@@configuration ||= Configuration.new
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3