blob: e6e1dffd456de41e581cdfea82c9b545d420a504 (
plain)
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
|
## diff.rb
module CodeRay module Scanners
class Diff < Scanner
register_for :diff
def scan_tokens tokens, options
until eos?
kind = :space
match = nil
# remove newlines
if scan(/\n/)
kind = :space
elsif scan(/^[+-]{3} .*$/)
kind = :diffhead
elsif scan(/^[+].*$/)
kind = :add
elsif scan(/^[-].*$/)
kind = :delete
elsif scan(/^[^ ].*$/)
kind = :diffhead
elsif scan(/^ .*$/)
kind = :space
else
getch
end
match ||= matched
raise [match, kind], tokens if kind == :error
tokens << [match, kind]
end
tokens
end
end
end end
## styles (cycnus) [plain]
.add { color:green; background:#dfd; }
.delete { color:red; background:#fdd; }
.diffhead { color:#999; background: #e7e7ff; }
## tokens (encoder/html/classes.rb)
ClassOfKind = {
:add => "add",
:delete => "delete",
:diffhead => "diffhead",
## example diff [diff]
Index: /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb
===================================================================
--- /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb (revision 1431)
+++ /Users/jgoebel/rails/pastie/app/controllers/pastes_controller.rb (revision 1437)
@@ -1,6 +1,10 @@
+require 'login_system'
require 'coderay'
class PastesController < ApplicationController
+ include LoginSystem
+
+ before_filter :attempt_cookie_login
# caches_action :recent
@@ -10,11 +14,7 @@
def show
@paste = Paste.find(params[:id])
- if params[:key] and params[:key]==User.new(@paste.nick).magic_mojo
- session[:login]=@paste.nick
- return redirect_to(:action => 'show', :id => @paste.id)
- end
-
+ attempt_key_login if not logged_in?
unless @paste.asset or not @paste.body.blank?
render :action => "edit"
end
|