aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl_gnutls.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-09-29 23:30:07 -0700
committerWilmer van der Gaast <wilmer@gaast.net>2010-09-29 23:30:07 -0700
commit560129adde5041ce5b9379a5225f6b3d4f31a1f9 (patch)
tree6ebdff8af05a8500ce085f97857392c82307707a /lib/ssl_gnutls.c
parent6ce2240e6dd88d86e90ffbfff078bc55b3f49477 (diff)
Fix use of g_convert(), thanks to an anonymous person who opened #676.
Diffstat (limited to 'lib/ssl_gnutls.c')
0 files changed, 0 insertions, 0 deletions
.1'>hotfix/0.20.0.1 Unnamed repository; edit this file 'description' to name the repository.MimesBrønn
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/willpaginate_extension.rb
blob: fa58bd9f0a3df3b57aeba7b430769a1b4291e99b (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
# this extension is loaded in environment.rb
module WillPaginateExtension
    class LinkRenderer < WillPaginate::ActionView::LinkRenderer
        def page_link(page, text, attributes = {})
            # Hack for admin pages, when proxied via https on mySociety servers, they
            # need a relative URL.
            url = url_for(page)
            if url.match(/\/admin.*(\?.*)/)
                url = $1
            end
            # Hack around our type-ahead search magic
            if url.match(/\/body\/search_ahead/)
                url.sub!("/body/search_ahead", "/select_authority")
            end
            @template.link_to text, url, attributes
        end

        # Returns URL params for +page_link_or_span+, taking the current GET params
        # and <tt>:params</tt> option into account.
        def url_for(page)
            page_one = page == 1
            unless @url_string and !page_one
                @url_params = {}
                # page links should preserve GET parameters
                stringified_merge @url_params, @template.params if @template.request.get?
                stringified_merge @url_params, @options[:params] if @options[:params]
                if complex = param_name.index(/[^\w-]/)
                    page_param = parse_query_parameters("#{param_name}=#{page}")
                    
                    stringified_merge @url_params, page_param
                else
                    @url_params[param_name] = page_one ? 1 : 2
                end
                # the following line makes pagination work on our specially munged search page
                combined = @template.request.path_parameters["combined"]
                @url_params["combined"] = combined if !combined.nil?
                url = @template.url_for(@url_params)
                return url if page_one
                
                if complex
                    @url_string = url.sub(%r!((?:\?|&amp;)#{CGI.escape param_name}=)#{page}!, "\\1\0")
                    return url
                else
                    @url_string = url
                    @url_params[param_name] = 3
                    @template.url_for(@url_params).split(//).each_with_index do |char, i|
                        if char == '3' and url[i, 1] == '2'
                            @url_string[i] = "\0"
                            break
                        end
                    end
                end
            end
            # finally!
            @url_string.sub "\0", page.to_s
        end

    end
end