mirah 0.0.7-java → 0.0.8-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +181 -0
- data/README.txt +6 -10
- data/Rakefile +86 -9
- data/bin/mirah +2 -0
- data/bin/mirahc +2 -0
- data/bin/mirahp +2 -0
- data/{bin/dubyp → examples/interfaces.mirah} +16 -9
- data/examples/macros/square.mirah +12 -0
- data/examples/macros/square_int.mirah +12 -0
- data/examples/macros/string-each-char.mirah +14 -0
- data/examples/maven/README.txt +2 -0
- data/examples/maven/pom.xml +23 -0
- data/examples/maven/src/main/mirah/hello_mirah.mirah +9 -0
- data/examples/rosettacode/100-doors.mirah +44 -0
- data/examples/rosettacode/99-bottles-of-beer.mirah +13 -0
- data/examples/rosettacode/README.txt +9 -0
- data/examples/rosettacode/boolean-values.mirah +29 -0
- data/examples/rosettacode/comments.mirah +2 -0
- data/examples/rosettacode/copy-a-string.mirah +10 -0
- data/examples/rosettacode/count-occurrences-of-a-substring.mirah +40 -0
- data/examples/rosettacode/create-a-file.mirah +6 -0
- data/examples/rosettacode/empty-string.mirah +9 -0
- data/examples/rosettacode/factorial.mirah +10 -0
- data/examples/rosettacode/fibonacci.mirah +21 -0
- data/examples/rosettacode/file-size.mirah +5 -0
- data/examples/rosettacode/fizz-buzz.mirah +21 -0
- data/examples/rosettacode/flatten-a-list.mirah +24 -0
- data/examples/rosettacode/guess-the-number.mirah +21 -0
- data/examples/rosettacode/is-string-numeric.mirah +127 -0
- data/examples/rosettacode/palindrome.mirah +14 -0
- data/examples/rosettacode/repeat-a-string.mirah +9 -0
- data/examples/rosettacode/reverse-a-string.mirah +6 -0
- data/examples/rosettacode/rot-13.mirah +20 -0
- data/examples/rosettacode/user-input.mirah +4 -0
- data/examples/sort_closure.mirah +1 -1
- data/javalib/dynalink-0.2.jar +0 -0
- data/javalib/mirah-bootstrap.jar +0 -0
- data/lib/mirah.rb +7 -16
- data/lib/mirah/ast.rb +22 -92
- data/lib/mirah/ast/call.rb +41 -9
- data/lib/mirah/ast/class.rb +34 -6
- data/lib/mirah/ast/flow.rb +17 -5
- data/lib/mirah/ast/intrinsics.rb +50 -8
- data/lib/mirah/ast/literal.rb +7 -0
- data/lib/mirah/ast/local.rb +9 -1
- data/lib/mirah/ast/method.rb +21 -8
- data/lib/mirah/ast/scope.rb +1 -1
- data/lib/mirah/ast/structure.rb +81 -15
- data/lib/mirah/ast/type.rb +4 -0
- data/{bin/dubyc → lib/mirah/commands.rb} +4 -11
- data/lib/mirah/commands/base.rb +54 -0
- data/lib/mirah/commands/compile.rb +39 -0
- data/{examples/wiki/Rakefile → lib/mirah/commands/parse.rb} +18 -17
- data/lib/mirah/commands/run.rb +73 -0
- data/lib/mirah/compiler.rb +37 -417
- data/lib/mirah/compiler/call.rb +45 -0
- data/lib/mirah/compiler/class.rb +81 -0
- data/lib/mirah/compiler/flow.rb +109 -0
- data/lib/mirah/compiler/literal.rb +130 -0
- data/lib/mirah/compiler/local.rb +59 -0
- data/lib/mirah/compiler/method.rb +44 -0
- data/lib/mirah/compiler/structure.rb +65 -0
- data/lib/mirah/compiler/type.rb +27 -0
- data/lib/mirah/env.rb +4 -6
- data/lib/mirah/generator.rb +61 -0
- data/lib/mirah/jvm/compiler.rb +8 -867
- data/lib/mirah/jvm/compiler/base.rb +270 -0
- data/lib/mirah/jvm/compiler/java_source.rb +779 -0
- data/lib/mirah/jvm/compiler/jvm_bytecode.rb +851 -0
- data/lib/mirah/jvm/method_lookup.rb +21 -2
- data/lib/mirah/jvm/source_generator/builder.rb +10 -13
- data/lib/mirah/jvm/source_generator/loops.rb +99 -93
- data/lib/mirah/jvm/source_generator/precompile.rb +3 -2
- data/lib/mirah/jvm/typer.rb +3 -3
- data/lib/mirah/jvm/types.rb +10 -426
- data/lib/mirah/jvm/types/array_type.rb +62 -0
- data/lib/mirah/jvm/types/basic_types.rb +1 -0
- data/lib/mirah/jvm/types/dynamic_type.rb +46 -0
- data/lib/mirah/jvm/types/factory.rb +23 -5
- data/lib/mirah/jvm/types/interface_definition.rb +20 -0
- data/lib/mirah/jvm/types/intrinsics.rb +15 -3
- data/lib/mirah/jvm/types/meta_type.rb +45 -0
- data/lib/mirah/jvm/types/methods.rb +12 -5
- data/lib/mirah/jvm/types/null_type.rb +27 -0
- data/lib/mirah/jvm/types/primitive_type.rb +38 -0
- data/lib/mirah/jvm/types/source_mirror.rb +266 -0
- data/lib/mirah/jvm/types/type.rb +173 -0
- data/lib/mirah/jvm/types/type_definition.rb +55 -0
- data/lib/mirah/jvm/types/unreachable_type.rb +27 -0
- data/lib/mirah/jvm/types/void_type.rb +19 -0
- data/lib/mirah/parser.rb +90 -0
- data/lib/mirah/plugin/gwt.rb +5 -5
- data/lib/mirah/plugin/java.rb +1 -1
- data/lib/mirah/transform.rb +4 -321
- data/lib/mirah/transform/ast_ext.rb +63 -0
- data/lib/mirah/transform/error.rb +13 -0
- data/lib/mirah/transform/helper.rb +761 -0
- data/lib/mirah/transform/transformer.rb +255 -0
- data/lib/mirah/typer.rb +2 -383
- data/{bin/duby → lib/mirah/typer/base.rb} +12 -10
- data/lib/mirah/typer/simple.rb +377 -0
- data/lib/mirah/util/argument_processor.rb +114 -0
- data/lib/mirah/util/class_loader.rb +37 -0
- data/lib/mirah/util/compilation_state.rb +51 -0
- data/lib/mirah/util/process_errors.rb +33 -0
- data/lib/mirah/version.rb +1 -1
- data/lib/mirah_task.rb +3 -2
- data/test/{test_ast.rb → core/test_ast.rb} +6 -0
- data/test/{test_compilation.rb → core/test_compilation.rb} +0 -0
- data/test/{test_env.rb → core/test_env.rb} +24 -25
- data/test/{test_macros.rb → core/test_macros.rb} +2 -4
- data/test/{test_typer.rb → core/test_typer.rb} +0 -3
- data/test/jvm/bytecode_test_helper.rb +181 -0
- data/test/{test_javac_compiler.rb → jvm/javac_test_helper.rb} +38 -22
- data/test/jvm/test_enumerable.rb +304 -0
- data/test/{test_java_typer.rb → jvm/test_java_typer.rb} +2 -4
- data/test/{test_jvm_compiler.rb → jvm/test_jvm_compiler.rb} +146 -443
- data/test/jvm/test_macros.rb +147 -0
- data/test/jvm/test_main_method.rb +15 -0
- data/test/{test_gwt.rb → plugins/test_gwt.rb} +0 -2
- metadata +103 -91
- data/bin/jrubyp +0 -52
- data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +0 -339
- data/examples/wiki/src/org/mirah/wiki/edit.eduby.html +0 -42
- data/examples/wiki/src/org/mirah/wiki/error.eduby.html +0 -2
- data/examples/wiki/src/org/mirah/wiki/layout.eduby.html +0 -69
- data/examples/wiki/src/org/mirah/wiki/parser.eduby.html +0 -7
- data/examples/wiki/src/org/mirah/wiki/view.eduby.html +0 -15
- data/examples/wiki/war/WEB-INF/classes/test/HeredocContext.class +0 -0
- data/examples/wiki/war/WEB-INF/classes/test/MirahParser.class +0 -0
- data/examples/wiki/war/WEB-INF/lib/appengine-api.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/jmeta-runtime.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/pegdown-stubs.jar +0 -0
- data/examples/wiki/war/WEB-INF/pegdown.jar +0 -0
- data/examples/wiki/war/app.yaml +0 -21
- data/examples/wiki/war/public/favicon.ico +0 -0
- data/examples/wiki/war/public/images/appengine_duby.png +0 -0
- data/examples/wiki/war/public/images/back.gif +0 -0
- data/examples/wiki/war/public/images/dir.gif +0 -0
- data/examples/wiki/war/public/images/file.gif +0 -0
- data/examples/wiki/war/public/javascripts/prettify.js +0 -61
- data/examples/wiki/war/public/robots.txt +0 -0
- data/examples/wiki/war/public/stylesheets/main.css +0 -156
- data/examples/wiki/war/public/stylesheets/prettify.css +0 -1
- data/examples/wiki/war/public/stylesheets/sh_style.css +0 -66
- data/examples/wiki/war/public/stylesheets/source.css +0 -21
- data/examples/wiki/war/public/wmd/images/bg-fill.png +0 -0
- data/examples/wiki/war/public/wmd/images/bg.png +0 -0
- data/examples/wiki/war/public/wmd/images/blockquote.png +0 -0
- data/examples/wiki/war/public/wmd/images/bold.png +0 -0
- data/examples/wiki/war/public/wmd/images/code.png +0 -0
- data/examples/wiki/war/public/wmd/images/h1.png +0 -0
- data/examples/wiki/war/public/wmd/images/hr.png +0 -0
- data/examples/wiki/war/public/wmd/images/img.png +0 -0
- data/examples/wiki/war/public/wmd/images/italic.png +0 -0
- data/examples/wiki/war/public/wmd/images/link.png +0 -0
- data/examples/wiki/war/public/wmd/images/ol.png +0 -0
- data/examples/wiki/war/public/wmd/images/redo.png +0 -0
- data/examples/wiki/war/public/wmd/images/separator.png +0 -0
- data/examples/wiki/war/public/wmd/images/ul.png +0 -0
- data/examples/wiki/war/public/wmd/images/undo.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd-on.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd.png +0 -0
- data/examples/wiki/war/public/wmd/showdown.js +0 -421
- data/examples/wiki/war/public/wmd/wmd-base.js +0 -1799
- data/examples/wiki/war/public/wmd/wmd-plus.js +0 -311
- data/examples/wiki/war/public/wmd/wmd.js +0 -73
- data/examples/wiki/war/src/org/mirah/wiki/MirahWiki.duby +0 -339
- data/examples/wiki/war/src/org/mirah/wiki/edit.eduby.html +0 -42
- data/examples/wiki/war/src/org/mirah/wiki/error.eduby.html +0 -2
- data/examples/wiki/war/src/org/mirah/wiki/layout.eduby.html +0 -69
- data/examples/wiki/war/src/org/mirah/wiki/parser.eduby.html +0 -7
- data/examples/wiki/war/src/org/mirah/wiki/view.eduby.html +0 -15
- data/javalib/dynalink-0.1.jar +0 -0
- data/javalib/jsr292-mock.jar +0 -0
- data/lib/mirah/class_loader.rb +0 -35
- data/lib/mirah/compilation_state.rb +0 -28
- data/lib/mirah/impl.rb +0 -273
- data/lib/mirah/jvm/base.rb +0 -267
- data/lib/mirah/jvm/source_compiler.rb +0 -760
- data/lib/mirah/transform2.rb +0 -752
data/bin/jrubyp
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#!/usr/bin/env jruby
|
2
|
-
|
3
|
-
# Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
|
4
|
-
# All contributing project authors may be found in the NOTICE file.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
$: << File.dirname(File.dirname(__FILE__)) + '/lib'
|
19
|
-
require 'mirah'
|
20
|
-
|
21
|
-
module Java::OrgJrubyparserAst
|
22
|
-
class Node
|
23
|
-
def pp(indent = 0)
|
24
|
-
return if self.invisible?
|
25
|
-
name = ""
|
26
|
-
name = ":#{self.name}" if respond_to? :getName
|
27
|
-
name += " #{value.inspect}" if respond_to? :getValue
|
28
|
-
name += " (#{depth})" if respond_to? :getDepth
|
29
|
-
print "#{' '*indent}(#{node_name}#{name}"
|
30
|
-
if child_nodes.size == 0
|
31
|
-
puts ')'
|
32
|
-
else
|
33
|
-
puts
|
34
|
-
indent += 2
|
35
|
-
child_nodes.each {|n| n.pp(indent)}
|
36
|
-
puts "#{' '*indent})"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
filename = ARGV.shift
|
43
|
-
case filename
|
44
|
-
when '-e'
|
45
|
-
contents = ARGV.join(' ')
|
46
|
-
when '-', nil
|
47
|
-
contents = $stdin.read
|
48
|
-
else
|
49
|
-
contents = IO.read(filename)
|
50
|
-
end
|
51
|
-
|
52
|
-
puts Duby::AST.parse_ruby(contents, filename).pp
|
@@ -1,339 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
|
2
|
-
# All contributing project authors may be found in the NOTICE file.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
|
16
|
-
import javax.servlet.http.HttpServlet
|
17
|
-
import javax.servlet.http.HttpServletRequest
|
18
|
-
import javax.servlet.Filter
|
19
|
-
import com.google.appengine.ext.duby.db.Model
|
20
|
-
import com.google.appengine.api.datastore.Text
|
21
|
-
import java.util.Date
|
22
|
-
import org.pegdown.PegDownProcessorStub
|
23
|
-
import com.google.appengine.api.users.UserServiceFactory
|
24
|
-
import com.google.appengine.api.users.User
|
25
|
-
import java.util.ArrayList
|
26
|
-
import java.util.List
|
27
|
-
|
28
|
-
class Page < Model
|
29
|
-
property 'title', String
|
30
|
-
property 'body', Text
|
31
|
-
property 'userid', String
|
32
|
-
property 'user', User
|
33
|
-
property 'nickname', String
|
34
|
-
property 'comment', String
|
35
|
-
property 'created', Date
|
36
|
-
property 'version', Long
|
37
|
-
property 'locked', Boolean
|
38
|
-
end
|
39
|
-
|
40
|
-
class Helper < HttpServlet
|
41
|
-
def markdown(text:String)
|
42
|
-
return "" unless text
|
43
|
-
flags = 0x5ff
|
44
|
-
if @allow_html
|
45
|
-
flags |= 0x200 unless @allow_html
|
46
|
-
@html_markdown ||= PegDownProcessorStub.new(flags)
|
47
|
-
@html_markdown.markdownToHtml(text)
|
48
|
-
else
|
49
|
-
@nohtml_markdown ||= PegDownProcessorStub.new(flags)
|
50
|
-
@nohtml_markdown.markdownToHtml(text)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def html=(enabled:boolean)
|
55
|
-
@allow_html = enabled
|
56
|
-
end
|
57
|
-
|
58
|
-
def page_name(name:String)
|
59
|
-
if name.nil?
|
60
|
-
return "Main"
|
61
|
-
else
|
62
|
-
name = name.replaceAll("\\W", "")
|
63
|
-
end
|
64
|
-
if name.equals("")
|
65
|
-
"Main"
|
66
|
-
else
|
67
|
-
name
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def h(text:String)
|
72
|
-
return "" unless text
|
73
|
-
text = text.replace("&", "&")
|
74
|
-
text = text.replace("<", "<")
|
75
|
-
text = text.replace(">", ">")
|
76
|
-
text = text.replace("\"", """)
|
77
|
-
text.replace("'", "'")
|
78
|
-
end
|
79
|
-
|
80
|
-
def h(o:Object)
|
81
|
-
h(o.toString)
|
82
|
-
end
|
83
|
-
|
84
|
-
def_edb(layout, 'org/mirah/wiki/layout.eduby.html')
|
85
|
-
|
86
|
-
def with_layout(content:String)
|
87
|
-
@content = content
|
88
|
-
layout
|
89
|
-
end
|
90
|
-
|
91
|
-
def title
|
92
|
-
@title
|
93
|
-
end
|
94
|
-
|
95
|
-
def title=(title:String)
|
96
|
-
@title = title
|
97
|
-
end
|
98
|
-
|
99
|
-
def users
|
100
|
-
@users ||= UserServiceFactory.getUserService()
|
101
|
-
end
|
102
|
-
|
103
|
-
macro def admin?
|
104
|
-
quote { users.isUserAdmin }
|
105
|
-
end
|
106
|
-
|
107
|
-
def user
|
108
|
-
users.getCurrentUser
|
109
|
-
end
|
110
|
-
|
111
|
-
def nickname
|
112
|
-
user.getNickname.replaceAll('@.*', '')
|
113
|
-
end
|
114
|
-
|
115
|
-
def extra_links
|
116
|
-
@links ||= ArrayList.new
|
117
|
-
end
|
118
|
-
|
119
|
-
def url
|
120
|
-
'/'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
class ViewPage < Helper
|
125
|
-
def_edb(view, 'org/mirah/wiki/view.eduby.html')
|
126
|
-
|
127
|
-
def doGet(request, response)
|
128
|
-
@url = request.getRequestURI
|
129
|
-
self.title = @name = page_name(request.getPathInfo)
|
130
|
-
canonical = "/" + @name
|
131
|
-
unless canonical.equals(request.getPathInfo)
|
132
|
-
response.sendRedirect(canonical)
|
133
|
-
return
|
134
|
-
end
|
135
|
-
|
136
|
-
@page = Page.get(@name)
|
137
|
-
self.html = @page.locked if @page
|
138
|
-
response.getWriter.write(with_layout(view))
|
139
|
-
end
|
140
|
-
|
141
|
-
def url
|
142
|
-
@url
|
143
|
-
end
|
144
|
-
|
145
|
-
def extra_links
|
146
|
-
links = ArrayList.new
|
147
|
-
if @page
|
148
|
-
can_edit = admin?
|
149
|
-
can_edit = true unless @page.locked
|
150
|
-
if can_edit
|
151
|
-
links.add(["Edit", "/edit/#{@page.title}"])
|
152
|
-
end
|
153
|
-
end
|
154
|
-
links.add(["New Page", "javascript:void(newPage())"])
|
155
|
-
links
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
import java.util.logging.Logger
|
160
|
-
|
161
|
-
class EditPage < Helper
|
162
|
-
def_edb(edit, 'org/mirah/wiki/edit.eduby.html')
|
163
|
-
def_edb(error, 'org/mirah/wiki/error.eduby.html')
|
164
|
-
|
165
|
-
def logger
|
166
|
-
@logger ||= Logger.getLogger("EditPage")
|
167
|
-
end
|
168
|
-
|
169
|
-
def render(content:String)
|
170
|
-
@response.setContentType("text/html; charset=utf-8")
|
171
|
-
@response.getWriter.write(with_layout(content))
|
172
|
-
end
|
173
|
-
|
174
|
-
def url
|
175
|
-
@url
|
176
|
-
end
|
177
|
-
|
178
|
-
def doGet(request, response)
|
179
|
-
@url = request.getRequestURI
|
180
|
-
@response = response
|
181
|
-
@error = String(nil)
|
182
|
-
@name = page_name(request.getPathInfo)
|
183
|
-
@page = Page.get(@name)
|
184
|
-
if @page && @page.locked
|
185
|
-
unless admin?
|
186
|
-
@error = "You are not authorized to edit this page"
|
187
|
-
response.setStatus(403)
|
188
|
-
render(error)
|
189
|
-
return
|
190
|
-
end
|
191
|
-
end
|
192
|
-
render(edit)
|
193
|
-
end
|
194
|
-
|
195
|
-
def doPost(_request, _response)
|
196
|
-
@error = nil
|
197
|
-
@response = _response
|
198
|
-
@url = _request.getRequestURI
|
199
|
-
|
200
|
-
# TODO scope inside blocks is not quite right
|
201
|
-
this = self
|
202
|
-
request = _request
|
203
|
-
response = _response
|
204
|
-
is_admin = admin?
|
205
|
-
|
206
|
-
name = page_name(request.getPathInfo)
|
207
|
-
|
208
|
-
begin
|
209
|
-
edit_version = Long.parseLong(String(request.getParameter("version")))
|
210
|
-
rescue NumberFormatException
|
211
|
-
response.sendError(
|
212
|
-
400, "Invalid version '#{request.getParameter("version")}'")
|
213
|
-
return
|
214
|
-
end
|
215
|
-
|
216
|
-
Model.transaction do
|
217
|
-
orig_page = Page.get(name)
|
218
|
-
current_version = orig_page ? orig_page.version : long(0)
|
219
|
-
if current_version != edit_version
|
220
|
-
@error = <<EOS
|
221
|
-
Version conflict. You are trying to edit version #{edit_version}, but
|
222
|
-
the current version is #{current_version}.
|
223
|
-
EOS
|
224
|
-
@page = orig_page
|
225
|
-
@name = name
|
226
|
-
response.setStatus(409)
|
227
|
-
this.render(this.edit)
|
228
|
-
return
|
229
|
-
end
|
230
|
-
if orig_page && orig_page.locked
|
231
|
-
unless is_admin
|
232
|
-
@error = "You are not authorized to edit this page"
|
233
|
-
response.setStatus(403)
|
234
|
-
this.render(this.error)
|
235
|
-
return
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
this.save_old_version(orig_page) if orig_page
|
240
|
-
|
241
|
-
if orig_page
|
242
|
-
page = orig_page
|
243
|
-
page.version = page.version + 1
|
244
|
-
else
|
245
|
-
page = Page.new(name)
|
246
|
-
page.title = name
|
247
|
-
page.version = 1
|
248
|
-
end
|
249
|
-
|
250
|
-
locked = is_admin && "locked".equals(request.getParameter("locked"))
|
251
|
-
page.body = String(request.getParameter("body"))
|
252
|
-
page.nickname = String(request.getParameter("nickname"))
|
253
|
-
page.comment = String(request.getParameter("comment"))
|
254
|
-
page.user = this.user
|
255
|
-
page.userid = this.user.getUserId
|
256
|
-
page.created = Date.new
|
257
|
-
page.locked = locked
|
258
|
-
page.save
|
259
|
-
response.sendRedirect("/wiki/" + name)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def save_old_version(orig_page:Page)
|
264
|
-
old_version = Page.new(orig_page)
|
265
|
-
old_version.title = orig_page.title
|
266
|
-
old_version.body = orig_page.body
|
267
|
-
old_version.userid = orig_page.userid
|
268
|
-
old_version.user = orig_page.user
|
269
|
-
old_version.nickname = orig_page.nickname
|
270
|
-
old_version.comment = orig_page.comment
|
271
|
-
old_version.created = orig_page.created
|
272
|
-
old_version.version = orig_page.version
|
273
|
-
old_version.locked = orig_page.locked
|
274
|
-
old_version.save
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
import test.MirahParser
|
279
|
-
import jmeta.BaseParser
|
280
|
-
class MirahParserPage < Helper
|
281
|
-
def_edb(render, 'org/mirah/wiki/parser.eduby.html')
|
282
|
-
|
283
|
-
def initialize
|
284
|
-
self.title = "Mirah Parser Test"
|
285
|
-
end
|
286
|
-
|
287
|
-
def doGet(request, response)
|
288
|
-
doPost(request, response)
|
289
|
-
end
|
290
|
-
|
291
|
-
def doPost(request, response)
|
292
|
-
@code = String(request.getParameter("code")) || "puts 'Hello, world!'"
|
293
|
-
parser = MirahParser.new
|
294
|
-
begin
|
295
|
-
@parsed = BaseParser.print_r(parser.parse(@code))
|
296
|
-
rescue => ex
|
297
|
-
@parsed = ex.getMessage
|
298
|
-
end
|
299
|
-
response.getWriter.write(with_layout(render))
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
class FederatedLogin < Helper
|
304
|
-
def doGet(request, response)
|
305
|
-
provider = request.getPathInfo
|
306
|
-
if provider && provider.length > 1
|
307
|
-
provider = provider.substring(1)
|
308
|
-
else
|
309
|
-
provider = 'www.google.com/accounts/o8/id'
|
310
|
-
end
|
311
|
-
continue = String(request.getParameter('continue')) || '/'
|
312
|
-
url = users.createLoginURL(continue, nil, provider, nil)
|
313
|
-
response.sendRedirect(url)
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
class LoginRequired < Helper
|
318
|
-
def doGet(request, response)
|
319
|
-
# This should be a page allowing people to select an OpenID provider.
|
320
|
-
# But I'm lazy so I'll just force them to use gmail...
|
321
|
-
continue = String(request.getParameter('continue'))
|
322
|
-
url = users.createLoginURL(continue, nil, 'www.google.com/accounts/o8/id', nil)
|
323
|
-
response.sendRedirect(url)
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
class MainFilter; implements Filter
|
328
|
-
def init(arg); end
|
329
|
-
def destroy; end
|
330
|
-
def doFilter(request, response, filters)
|
331
|
-
if "/".equals(HttpServletRequest(request).getRequestURI)
|
332
|
-
request.getRequestDispatcher('/wiki/Main').forward(request, response)
|
333
|
-
nil
|
334
|
-
else
|
335
|
-
filters.doFilter(request, response)
|
336
|
-
nil
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<div>
|
2
|
-
<% if @error %>
|
3
|
-
<div id=error><%=h @error %></div>
|
4
|
-
<% end %>
|
5
|
-
<div>
|
6
|
-
<form method=post>
|
7
|
-
<textarea id=body name=body style="width:95%;font-family:monospace" rows=5
|
8
|
-
><% if @page && @page.body %><%=h @page.body %><% end
|
9
|
-
%></textarea><br>
|
10
|
-
Your Name: <input name=nickname value="<%=h nickname %>"><br>
|
11
|
-
Comment: <input name=comment value=<% if @page %>
|
12
|
-
"Edited Page"
|
13
|
-
<% else %>
|
14
|
-
"Created Page"
|
15
|
-
<% end %>><br>
|
16
|
-
<input type=hidden name=version value="<%= @page ? @page.version : long(0) %>">
|
17
|
-
<% if admin? %>
|
18
|
-
Locked: <input name=locked value=locked type=checkbox <%= "checked" if @page && @page.locked%>><br>
|
19
|
-
<% end %>
|
20
|
-
<input type=submit name=Save>
|
21
|
-
</form>
|
22
|
-
</div>
|
23
|
-
<hr style="clear:all">
|
24
|
-
<div id=preview class="wmd-preview"></div>
|
25
|
-
<script>
|
26
|
-
(function(){
|
27
|
-
var ta = document.getElementById("body");
|
28
|
-
var sh = 0;
|
29
|
-
function resize() {
|
30
|
-
var nsh = ta.scrollHeight;
|
31
|
-
if (nsh != sh) {
|
32
|
-
ta.style.height = 0;
|
33
|
-
ta.style.height = (nsh + 100) + "px";
|
34
|
-
sh = ta.scrollHeight;
|
35
|
-
}
|
36
|
-
setTimeout(resize, 250);
|
37
|
-
}
|
38
|
-
resize();
|
39
|
-
})();
|
40
|
-
wmd_options={output:"markdown"};
|
41
|
-
</script>
|
42
|
-
<script type="text/javascript" src="/wmd/wmd.js""></script>
|
@@ -1,69 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
5
|
-
<title><%=h @title %></title>
|
6
|
-
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css">
|
7
|
-
<link href="/stylesheets/prettify.css" type="text/css" rel="stylesheet" />
|
8
|
-
<script type="text/javascript" src="/javascripts/prettify.js"></script>
|
9
|
-
</head>
|
10
|
-
<body onload="prettyPrint()">
|
11
|
-
<div id="page">
|
12
|
-
<div id="sidebar">
|
13
|
-
|
14
|
-
<h1>Mirah</h1>
|
15
|
-
|
16
|
-
<ul id="sidebar-items">
|
17
|
-
|
18
|
-
<li>
|
19
|
-
<h3>Join the community</h3>
|
20
|
-
<ul class="links">
|
21
|
-
<li><a href="/">Home Page</a></li>
|
22
|
-
<li><a href="http://github.com/mirah/mirah">github</a></li>
|
23
|
-
<li><a href="/wiki/Resources">Resources</a></li>
|
24
|
-
<li><a href="/wiki/MirahHowto">Howto</a></li>
|
25
|
-
<li><a
|
26
|
-
href="http://groups.google.com/group/mirah/"
|
27
|
-
target="_new">Send Feedback</a></li>
|
28
|
-
</ul>
|
29
|
-
</li>
|
30
|
-
|
31
|
-
<li>
|
32
|
-
<h3>Sample Apps</h3>
|
33
|
-
<ul class="links">
|
34
|
-
<li><a href="http://github.com/mirah/mirah/tree/master/examples/appengine/">Guestbook</a> |
|
35
|
-
<a href="http://github.com/jacortinas/appengine-rails-jquery-demo">Mustache</a></li>
|
36
|
-
</ul>
|
37
|
-
<a href="/wiki/MirahSamples">Sample Code</a>
|
38
|
-
</li>
|
39
|
-
|
40
|
-
<li>
|
41
|
-
<h3>Mirah Videos</h3>
|
42
|
-
<ul class="links">
|
43
|
-
<li><a href="http://www.youtube.com/watch?v=08rNKxW0PPo">ribrdb</a> |
|
44
|
-
<a href="http://confreaks.net/videos/196-rubyconf2009-ruby-mutants">headius</a></li>
|
45
|
-
</ul>
|
46
|
-
</li>
|
47
|
-
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<div id="content">
|
51
|
-
<div id=hlinks>
|
52
|
-
<% if user %>
|
53
|
-
<%=h user.getEmail %> |
|
54
|
-
<% extra_links.each do |_pair|;pair = List(_pair) %>
|
55
|
-
<a href="<%=h pair.get(1)%>"><%=h pair.get(0)%></a> |
|
56
|
-
<% end %>
|
57
|
-
<a href="<%=h users.createLogoutURL('/')%>">Sign Out</a>
|
58
|
-
<% else %>
|
59
|
-
<a href="<%=users.createLoginURL(url)%>">Sign In</a>
|
60
|
-
<% end %>
|
61
|
-
</div>
|
62
|
-
<div id=wikicontent>
|
63
|
-
<%= @content %>
|
64
|
-
</div>
|
65
|
-
</div>
|
66
|
-
</div>
|
67
|
-
</body>
|
68
|
-
</html>
|
69
|
-
|