Revision 1297:0a574315af3e .svn/pristine/ac
| .svn/pristine/ac/ac26075ed3d7e3fbdfe96b667d5f07f279649046.svn-base | ||
|---|---|---|
| 1 |
class Meeting < ActiveRecord::Base |
|
| 2 |
belongs_to :project |
|
| 3 |
|
|
| 4 |
acts_as_event :title => Proc.new {|o| "#{o.scheduled_on} Meeting"},
|
|
| 5 |
:datetime => :scheduled_on, |
|
| 6 |
:author => nil, |
|
| 7 |
:url => Proc.new {|o| {:controller => 'meetings', :action => 'show', :id => o.id}}
|
|
| 8 |
|
|
| 9 |
acts_as_activity_provider :timestamp => 'scheduled_on', |
|
| 10 |
:find_options => { :include => :project }
|
|
| 11 |
end |
|
| .svn/pristine/ac/ac29e4943c6b7f06073e396c00b1a9f4120db8e8.svn-base | ||
|---|---|---|
| 1 |
<div class="contextual"> |
|
| 2 |
<%= watcher_tag(@wiki, User.current) %> |
|
| 3 |
</div> |
|
| 4 |
|
|
| 5 |
<h2><%= l(:label_index_by_title) %></h2> |
|
| 6 |
|
|
| 7 |
<% if @pages.empty? %> |
|
| 8 |
<p class="nodata"><%= l(:label_no_data) %></p> |
|
| 9 |
<% end %> |
|
| 10 |
|
|
| 11 |
<%= render_page_hierarchy(@pages_by_parent_id, nil, :timestamp => true) %> |
|
| 12 |
|
|
| 13 |
<% content_for :sidebar do %> |
|
| 14 |
<%= render :partial => 'sidebar' %> |
|
| 15 |
<% end %> |
|
| 16 |
|
|
| 17 |
<% unless @pages.empty? %> |
|
| 18 |
<% other_formats_links do |f| %> |
|
| 19 |
<%= f.link_to 'Atom', |
|
| 20 |
:url => {:controller => 'activities', :action => 'index',
|
|
| 21 |
:id => @project, :show_wiki_edits => 1, |
|
| 22 |
:key => User.current.rss_key} %> |
|
| 23 |
<% if User.current.allowed_to?(:export_wiki_pages, @project) %> |
|
| 24 |
<%= f.link_to('PDF', :url => {:action => 'export', :format => 'pdf'}) %>
|
|
| 25 |
<%= f.link_to('HTML', :url => {:action => 'export'}) %>
|
|
| 26 |
<% end %> |
|
| 27 |
<% end %> |
|
| 28 |
<% end %> |
|
| 29 |
|
|
| 30 |
<% content_for :header_tags do %> |
|
| 31 |
<%= auto_discovery_link_tag( |
|
| 32 |
:atom, :controller => 'activities', :action => 'index', |
|
| 33 |
:id => @project, :show_wiki_edits => 1, :format => 'atom', |
|
| 34 |
:key => User.current.rss_key) %> |
|
| 35 |
<% end %> |
|
| .svn/pristine/ac/ac3a2ee58099c23648eac79beac2eb4ee2a7c013.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class WikiPageTest < ActiveSupport::TestCase |
|
| 21 |
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions |
|
| 22 |
|
|
| 23 |
def setup |
|
| 24 |
@wiki = Wiki.find(1) |
|
| 25 |
@page = @wiki.pages.first |
|
| 26 |
end |
|
| 27 |
|
|
| 28 |
def test_create |
|
| 29 |
page = WikiPage.new(:wiki => @wiki) |
|
| 30 |
assert !page.save |
|
| 31 |
assert_equal 1, page.errors.count |
|
| 32 |
|
|
| 33 |
page.title = "Page" |
|
| 34 |
assert page.save |
|
| 35 |
page.reload |
|
| 36 |
assert !page.protected? |
|
| 37 |
|
|
| 38 |
@wiki.reload |
|
| 39 |
assert @wiki.pages.include?(page) |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
def test_sidebar_should_be_protected_by_default |
|
| 43 |
page = @wiki.find_or_new_page('sidebar')
|
|
| 44 |
assert page.new_record? |
|
| 45 |
assert page.protected? |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
def test_find_or_new_page |
|
| 49 |
page = @wiki.find_or_new_page("CookBook documentation")
|
|
| 50 |
assert_kind_of WikiPage, page |
|
| 51 |
assert !page.new_record? |
|
| 52 |
|
|
| 53 |
page = @wiki.find_or_new_page("Non existing page")
|
|
| 54 |
assert_kind_of WikiPage, page |
|
| 55 |
assert page.new_record? |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
def test_parent_title |
|
| 59 |
page = WikiPage.find_by_title('Another_page')
|
|
| 60 |
assert_nil page.parent_title |
|
| 61 |
|
|
| 62 |
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
|
| 63 |
assert_equal 'CookBook documentation', page.parent_title |
|
| 64 |
end |
|
| 65 |
|
|
| 66 |
def test_assign_parent |
|
| 67 |
page = WikiPage.find_by_title('Another_page')
|
|
| 68 |
page.parent_title = 'CookBook documentation' |
|
| 69 |
assert page.save |
|
| 70 |
page.reload |
|
| 71 |
assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent
|
|
| 72 |
end |
|
| 73 |
|
|
| 74 |
def test_unassign_parent |
|
| 75 |
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
|
| 76 |
page.parent_title = '' |
|
| 77 |
assert page.save |
|
| 78 |
page.reload |
|
| 79 |
assert_nil page.parent |
|
| 80 |
end |
|
| 81 |
|
|
| 82 |
def test_parent_validation |
|
| 83 |
page = WikiPage.find_by_title('CookBook_documentation')
|
|
| 84 |
|
|
| 85 |
# A page that doesn't exist |
|
| 86 |
page.parent_title = 'Unknown title' |
|
| 87 |
assert !page.save |
|
| 88 |
assert_include I18n.translate('activerecord.errors.messages.invalid'),
|
|
| 89 |
page.errors[:parent_title] |
|
| 90 |
# A child page |
|
| 91 |
page.parent_title = 'Page_with_an_inline_image' |
|
| 92 |
assert !page.save |
|
| 93 |
assert_include I18n.translate('activerecord.errors.messages.circular_dependency'),
|
|
| 94 |
page.errors[:parent_title] |
|
| 95 |
# The page itself |
|
| 96 |
page.parent_title = 'CookBook_documentation' |
|
| 97 |
assert !page.save |
|
| 98 |
assert_include I18n.translate('activerecord.errors.messages.circular_dependency'),
|
|
| 99 |
page.errors[:parent_title] |
|
| 100 |
page.parent_title = 'Another_page' |
|
| 101 |
assert page.save |
|
| 102 |
end |
|
| 103 |
|
|
| 104 |
def test_destroy |
|
| 105 |
page = WikiPage.find(1) |
|
| 106 |
page.destroy |
|
| 107 |
assert_nil WikiPage.find_by_id(1) |
|
| 108 |
# make sure that page content and its history are deleted |
|
| 109 |
assert WikiContent.find_all_by_page_id(1).empty? |
|
| 110 |
assert WikiContent.versioned_class.find_all_by_page_id(1).empty? |
|
| 111 |
end |
|
| 112 |
|
|
| 113 |
def test_destroy_should_not_nullify_children |
|
| 114 |
page = WikiPage.find(2) |
|
| 115 |
child_ids = page.child_ids |
|
| 116 |
assert child_ids.any? |
|
| 117 |
page.destroy |
|
| 118 |
assert_nil WikiPage.find_by_id(2) |
|
| 119 |
|
|
| 120 |
children = WikiPage.find_all_by_id(child_ids) |
|
| 121 |
assert_equal child_ids.size, children.size |
|
| 122 |
children.each do |child| |
|
| 123 |
assert_nil child.parent_id |
|
| 124 |
end |
|
| 125 |
end |
|
| 126 |
|
|
| 127 |
def test_updated_on_eager_load |
|
| 128 |
page = WikiPage.with_updated_on.first(:order => 'id') |
|
| 129 |
assert page.is_a?(WikiPage) |
|
| 130 |
assert_not_nil page.read_attribute(:updated_on) |
|
| 131 |
assert_equal Time.gm(2007, 3, 6, 23, 10, 51), page.content.updated_on |
|
| 132 |
assert_equal page.content.updated_on, page.updated_on |
|
| 133 |
assert_not_nil page.read_attribute(:version) |
|
| 134 |
end |
|
| 135 |
|
|
| 136 |
def test_descendants |
|
| 137 |
page = WikiPage.create!(:wiki => @wiki, :title => 'Parent') |
|
| 138 |
child1 = WikiPage.create!(:wiki => @wiki, :title => 'Child1', :parent => page) |
|
| 139 |
child11 = WikiPage.create!(:wiki => @wiki, :title => 'Child11', :parent => child1) |
|
| 140 |
child111 = WikiPage.create!(:wiki => @wiki, :title => 'Child111', :parent => child11) |
|
| 141 |
child2 = WikiPage.create!(:wiki => @wiki, :title => 'Child2', :parent => page) |
|
| 142 |
|
|
| 143 |
assert_equal %w(Child1 Child11 Child111 Child2), page.descendants.map(&:title).sort |
|
| 144 |
assert_equal %w(Child1 Child11 Child111 Child2), page.descendants(nil).map(&:title).sort |
|
| 145 |
assert_equal %w(Child1 Child11 Child2), page.descendants(2).map(&:title).sort |
|
| 146 |
assert_equal %w(Child1 Child2), page.descendants(1).map(&:title).sort |
|
| 147 |
|
|
| 148 |
assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants.map(&:title).sort |
|
| 149 |
assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants(nil).map(&:title).sort |
|
| 150 |
assert_equal %w(Child1 Child11 Child2 Parent), page.self_and_descendants(2).map(&:title).sort |
|
| 151 |
assert_equal %w(Child1 Child2 Parent), page.self_and_descendants(1).map(&:title).sort |
|
| 152 |
end |
|
| 153 |
|
|
| 154 |
def test_diff_for_page_with_deleted_version_should_pick_the_previous_available_version |
|
| 155 |
WikiContent::Version.find_by_page_id_and_version(1, 2).destroy |
|
| 156 |
|
|
| 157 |
page = WikiPage.find(1) |
|
| 158 |
diff = page.diff(3) |
|
| 159 |
assert_not_nil diff |
|
| 160 |
assert_equal 3, diff.content_to.version |
|
| 161 |
assert_equal 1, diff.content_from.version |
|
| 162 |
end |
|
| 163 |
end |
|
| .svn/pristine/ac/ac3cb3eefdd851a5f9d663d9f434eeb017054b9d.svn-base | ||
|---|---|---|
| 1 |
# Default setup is given for MySQL with ruby1.8. If you're running Redmine |
|
| 2 |
# with MySQL and ruby1.9, replace the adapter name with `mysql2`. |
|
| 3 |
# Examples for PostgreSQL and SQLite3 can be found at the end. |
|
| 4 |
|
|
| 5 |
production: |
|
| 6 |
adapter: mysql |
|
| 7 |
database: redmine |
|
| 8 |
host: localhost |
|
| 9 |
username: root |
|
| 10 |
password: "" |
|
| 11 |
encoding: utf8 |
|
| 12 |
|
|
| 13 |
development: |
|
| 14 |
adapter: mysql |
|
| 15 |
database: redmine_development |
|
| 16 |
host: localhost |
|
| 17 |
username: root |
|
| 18 |
password: "" |
|
| 19 |
encoding: utf8 |
|
| 20 |
|
|
| 21 |
# Warning: The database defined as "test" will be erased and |
|
| 22 |
# re-generated from your development database when you run "rake". |
|
| 23 |
# Do not set this db to the same as development or production. |
|
| 24 |
test: |
|
| 25 |
adapter: mysql |
|
| 26 |
database: redmine_test |
|
| 27 |
host: localhost |
|
| 28 |
username: root |
|
| 29 |
password: "" |
|
| 30 |
encoding: utf8 |
|
| 31 |
|
|
| 32 |
test_pgsql: |
|
| 33 |
adapter: postgresql |
|
| 34 |
database: redmine_test |
|
| 35 |
host: localhost |
|
| 36 |
username: postgres |
|
| 37 |
password: "postgres" |
|
| 38 |
|
|
| 39 |
test_sqlite3: |
|
| 40 |
adapter: sqlite3 |
|
| 41 |
database: db/test.sqlite3 |
|
| .svn/pristine/ac/ac80a0a0728af94588c2f8cce1549e26340e25ff.svn-base | ||
|---|---|---|
| 1 |
desc 'Generates a secret token for the application.' |
|
| 2 |
|
|
| 3 |
file 'config/initializers/secret_token.rb' do |
|
| 4 |
path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb') |
|
| 5 |
secret = SecureRandom.hex(40) |
|
| 6 |
File.open(path, 'w') do |f| |
|
| 7 |
f.write <<"EOF" |
|
| 8 |
# This file was generated by 'rake generate_secret_token', and should |
|
| 9 |
# not be made visible to public. |
|
| 10 |
# If you have a load-balancing Redmine cluster, you will need to use the |
|
| 11 |
# same version of this file on each machine. And be sure to restart your |
|
| 12 |
# server when you modify this file. |
|
| 13 |
# |
|
| 14 |
# Your secret key for verifying cookie session data integrity. If you |
|
| 15 |
# change this key, all old sessions will become invalid! Make sure the |
|
| 16 |
# secret is at least 30 characters and all random, no regular words or |
|
| 17 |
# you'll be exposed to dictionary attacks. |
|
| 18 |
RedmineApp::Application.config.secret_token = '#{secret}'
|
|
| 19 |
EOF |
|
| 20 |
end |
|
| 21 |
end |
|
| 22 |
|
|
| 23 |
desc 'Generates a secret token for the application.' |
|
| 24 |
task :generate_secret_token => ['config/initializers/secret_token.rb'] |
|
| .svn/pristine/ac/acb16fb7d1a43ca9b265d3fc139a9a8c3d61e7c6.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
class SearchController < ApplicationController |
|
| 19 |
before_filter :find_optional_project |
|
| 20 |
|
|
| 21 |
helper :messages |
|
| 22 |
include MessagesHelper |
|
| 23 |
|
|
| 24 |
def index |
|
| 25 |
@question = params[:q] || "" |
|
| 26 |
@question.strip! |
|
| 27 |
@all_words = params[:all_words] ? params[:all_words].present? : true |
|
| 28 |
@titles_only = params[:titles_only] ? params[:titles_only].present? : false |
|
| 29 |
|
|
| 30 |
projects_to_search = |
|
| 31 |
case params[:scope] |
|
| 32 |
when 'all' |
|
| 33 |
nil |
|
| 34 |
when 'my_projects' |
|
| 35 |
User.current.memberships.collect(&:project) |
|
| 36 |
when 'subprojects' |
|
| 37 |
@project ? (@project.self_and_descendants.active.all) : nil |
|
| 38 |
else |
|
| 39 |
@project |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
offset = nil |
|
| 43 |
begin; offset = params[:offset].to_time if params[:offset]; rescue; end |
|
| 44 |
|
|
| 45 |
# quick jump to an issue |
|
| 46 |
if @question.match(/^#?(\d+)$/) && Issue.visible.find_by_id($1.to_i) |
|
| 47 |
redirect_to :controller => "issues", :action => "show", :id => $1 |
|
| 48 |
return |
|
| 49 |
end |
|
| 50 |
|
|
| 51 |
@object_types = Redmine::Search.available_search_types.dup |
|
| 52 |
if projects_to_search.is_a? Project |
|
| 53 |
# don't search projects |
|
| 54 |
@object_types.delete('projects')
|
|
| 55 |
# only show what the user is allowed to view |
|
| 56 |
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, projects_to_search)}
|
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
@scope = @object_types.select {|t| params[t]}
|
|
| 60 |
@scope = @object_types if @scope.empty? |
|
| 61 |
|
|
| 62 |
# extract tokens from the question |
|
| 63 |
# eg. hello "bye bye" => ["hello", "bye bye"] |
|
| 64 |
@tokens = @question.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
|
|
| 65 |
# tokens must be at least 2 characters long |
|
| 66 |
@tokens = @tokens.uniq.select {|w| w.length > 1 }
|
|
| 67 |
|
|
| 68 |
if !@tokens.empty? |
|
| 69 |
# no more than 5 tokens to search for |
|
| 70 |
@tokens.slice! 5..-1 if @tokens.size > 5 |
|
| 71 |
|
|
| 72 |
@results = [] |
|
| 73 |
@results_by_type = Hash.new {|h,k| h[k] = 0}
|
|
| 74 |
|
|
| 75 |
limit = 10 |
|
| 76 |
@scope.each do |s| |
|
| 77 |
r, c = s.singularize.camelcase.constantize.search(@tokens, projects_to_search, |
|
| 78 |
:all_words => @all_words, |
|
| 79 |
:titles_only => @titles_only, |
|
| 80 |
:limit => (limit+1), |
|
| 81 |
:offset => offset, |
|
| 82 |
:before => params[:previous].nil?) |
|
| 83 |
@results += r |
|
| 84 |
@results_by_type[s] += c |
|
| 85 |
end |
|
| 86 |
@results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime}
|
|
| 87 |
if params[:previous].nil? |
|
| 88 |
@pagination_previous_date = @results[0].event_datetime if offset && @results[0] |
|
| 89 |
if @results.size > limit |
|
| 90 |
@pagination_next_date = @results[limit-1].event_datetime |
|
| 91 |
@results = @results[0, limit] |
|
| 92 |
end |
|
| 93 |
else |
|
| 94 |
@pagination_next_date = @results[-1].event_datetime if offset && @results[-1] |
|
| 95 |
if @results.size > limit |
|
| 96 |
@pagination_previous_date = @results[-(limit)].event_datetime |
|
| 97 |
@results = @results[-(limit), limit] |
|
| 98 |
end |
|
| 99 |
end |
|
| 100 |
else |
|
| 101 |
@question = "" |
|
| 102 |
end |
|
| 103 |
render :layout => false if request.xhr? |
|
| 104 |
end |
|
| 105 |
|
|
| 106 |
private |
|
| 107 |
def find_optional_project |
|
| 108 |
return true unless params[:id] |
|
| 109 |
@project = Project.find(params[:id]) |
|
| 110 |
check_project_privacy |
|
| 111 |
rescue ActiveRecord::RecordNotFound |
|
| 112 |
render_404 |
|
| 113 |
end |
|
| 114 |
end |
|
| .svn/pristine/ac/acc250b05e43c21173623b65f651d52d843f6f14.svn-base | ||
|---|---|---|
| 1 |
FWIW - I am migrating my apps to Prawn and Prawnto |
|
| 2 |
|
|
| 3 |
= RFPDF Template Plugin |
|
| 4 |
|
|
| 5 |
A template plugin allowing the inclusion of ERB-enabled RFPDF template files. |
|
| 6 |
|
|
| 7 |
== |
|
| 8 |
== |
|
| 9 |
== TCPDF Version (The New or UTF8 Version) |
|
| 10 |
== |
|
| 11 |
== |
|
| 12 |
|
|
| 13 |
TCPDF Documentation located at: |
|
| 14 |
|
|
| 15 |
http://phpdocs.moodle.org/com-tecnick-tcpdf/TCPDF.html |
|
| 16 |
|
|
| 17 |
Example of simple use in .rhtml: |
|
| 18 |
|
|
| 19 |
<% |
|
| 20 |
@pdf = TCPDF.new() |
|
| 21 |
@pdf.SetMargins(15, 27, 15); |
|
| 22 |
@pdf.AddPage(); |
|
| 23 |
text_options = {:font => "freeserif"}
|
|
| 24 |
@pdf.draw_text(15, 10, "text", {:font_size => 12, :font => "freeserif"})
|
|
| 25 |
%><%=@pdf.Output()%> |
|
| 26 |
|
|
| 27 |
See the following files for sample of useage: |
|
| 28 |
|
|
| 29 |
test_unicode.rfpdf |
|
| 30 |
utf8test.txt |
|
| 31 |
logo_example.png |
|
| 32 |
|
|
| 33 |
FPDF users can migrate to TCPDF by changing the following from: |
|
| 34 |
|
|
| 35 |
pdf = FPDF.new |
|
| 36 |
|
|
| 37 |
to: |
|
| 38 |
|
|
| 39 |
pdf = TCPDF.new |
|
| 40 |
|
|
| 41 |
ENJOY! |
|
Also available in: Unified diff