Home
JQuery: Check Form Values have changed before leaving page.
- Details
If you want the behavior that when someone changes data in a form and doesn't submit it, that they are alerted they are about to leave the page without saving/submitting. Jquery has some great functionality.
You will want your form submit to set the var used_submit to something other than 0
<input type="submit" onclick="CleanLeavePage();" value="Save">
<script type="text/javascript">
var sform_clean;
var used_submit = 0;
// When the page load we get the values serialize
$(function() {
sform_clean = $("form").serialize();
});
// Before we leave the page we now compare between the new form values and the orignal
window.onbeforeunload = function (e) {
var sform_dirty = $("form").serialize();
if(sform_clean != sform_dirty && used_submit ==0) {
return 'You are about to leave a page where you have not saved the data';
}
};
function CleanLeavePage(){
used_submit = 1;
}
</script>
Redmine - SVN
- Details
Now that you have your Redmine server working you may want to add SVN to it.
First you will need to install some things.
mkdir /var/svn
chown root:www-data /var/svn
chmod 0750 /var/svn
cd /var/www/vhosts/redmine/extra/svn/ruby reposman.rb --redmine www.yoursite.com --svn-dir /var/svn --owner www-data --url http://www.yoursite.com/svn/ --key=KeyFromWebAdminRedmine
cp /var/www/vhosts/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
apt-get install libapache2-svn
apt-get install libapache-dbi-perl
apt-get install libapache2-mod-perl2
apt-get install libdbd-mysql-perl libdigest-sha1-perl
apt-get install libdbd-mysql-perl
a2enmod perl
cd /etc/apache2/sites-available/
nano default
------------------------------------------------------------------- add to your existing port 80 site. after </Directory>---------------------------
# /svn location for users
PerlLoadModule Apache::Redmine
<Location /svn>
DAV svn
SVNParentPath "/var/svn"
Order deny,allow
Deny from all
Satisfy any
# If a client tries to svn update which involves updating many files,
# the update request might result in an error Server sent unexpected
# return value (413 Request Entity Too Large) in response to REPORT
# request,because the size of the update request exceeds the limit
# allowed by the server. You can avoid this error by disabling the
# request size limit by adding the line LimitXMLRequestBody 0
# between the <Location...> and </Location> lines.
LimitXMLRequestBody 0
# Only check Authentication for root path, nor again for recursive
# folder.
# Redmine core does only permit access on repository level, so this
# doesn't hurt security. On the other hand it does boost performance
# a lot!
SVNPathAuthz off
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
AuthType Basic
AuthName "Redmine SVN Repository"
#read-only access
<Limit GET PROPFIND OPTIONS REPORT>
Require valid-user
Allow from 192.168.1.55
# Allow from another-ip
Satisfy any
</Limit>
# write access
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
## for mysql
RedmineDSN "DBI:mysql:database=redmine;host=localhost"
RedmineDbUser "redmine-user"
RedmineDbPass "redminepassword"
</Location>
---------------------------------------------------------------------- end add --------------------------------------------------------
service apache2 restart
You may want to automate the repository discovery by adding a cron job.
I added created a file called pullrepos.sh
------------------------------------------------------- this is the content of that file -----------------------------------------------------
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p429
TERM=xterm
SHELL=/bin/bash
IRBRC=/usr/local/rvm/rubies/ruby-1.9.3-p429/.irbrc
OLDPWD=/var/www/vhosts/redmine
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-1.9.3-p429
SSH_TTY=/dev/pts/0
USER=root
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
MAIL=/var/mail/root
PATH=/usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p429/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/usr/bin
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global
RUBY_VERSION=ruby-1.9.3-p429
cd /var/www/vhosts/redmine/extra/svn/
ruby reposman.rb --redmine www.yoursite.com --svn-dir /var/svn --owner www-data --url http://www.yoursite.com/svn/ --key=KeyFromWebAdminRedmine
------------------------------------------------------- end of content-----------------------------------------------------
I'll run this file every :10 of the hour to check for new projects
crontab -e -u www-data
10 * * * * /var/www/vhosts/redmine/pullrepos.sh
Redmine Cron and rake
- Details
You will need to make your .sh script work from command line first.
This is just to help you getting it to work with cron
First make your .sh script.
Get your full path first.
$ echo $PATH
now copy that path down because you will want it for your script.
In the below script change PATH= to whatever your path was from above $ nano runrakes.sh
#!/usr/bin/env ruby
PATH=/usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin....etc....
cd /var/www/vhosts/redmine
/usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake -f /var/www/vhosts/redmine/Rakefile redmine:email:receive_pop3 RAILS_ENV="production" host=10.10.1.55 username=emailpopusername password=mypassword
now make a cron task for the web user. This is set to run every 5 minutes. If you have a lot of email traffic you may want to make it something closer to 30 minutes.
crontab -e -u www-data
*/5 * * * * /var/www/vhosts/redmine/runrakes.sh
Now your emails or script for rake should run.
If you run into issues after the security updates. you can do this:
$ env
copy all the vars
with the exception of any that fail when you try to run it via command line for testing.
remove: #!/usr/bin/env ruby
paste all the vars there
$ nano runrakes.sh
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p429
TERM=xterm
SHELL=/bin/bash
IRBRC=/usr/local/rvm/rubies/ruby-1.9.3-p429/.irbrc
OLDPWD=/var/www/vhosts/redmine
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-1.9.3-p429
SSH_TTY=/dev/pts/0
USER=root
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
MAIL=/var/mail/root
PATH=/usr/local/rvm/gems/ruby-1.9.3-p429/bin:etc......
PWD=/usr/bin
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global
RUBY_VERSION=ruby-1.9.3-p429
cd /var/www/vhosts/redmine
/usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake -f /var/www/vhosts/redmine/Rakefile redmine:email:receive_pop3 RAILS_ENV="production" host=10.10.1.55 username=emailpopusername password=mypassword
Redmine Install pit falls with apache
- Details
But... if you can't go to your redmine directory and run:
$ ruby script/rails server webrick -e production
then browse http://yourserverip:3000
This article will not help you
This assumes you have a working Redmine with ruby
First off you will want to disable the apache passenger:
$ a2dismod passenger
You will want to run the script that builds the passenger:
you should be using rvm if your not then owell.
I went to my current build wrapper:
$cd /usr/local/rvm/wrappers/ruby-1.9.3-p429
then I ran:
$ ./passenger-install-apache2-module
I was missing a bunch of stuff so I apt-get all the stuff missing and run it again
you should see it building.
it will then tell you to modify apache config:
$ nano /etc/apache2/apache2.conf I added to the top of the config:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.2/libout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.2
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p429/ruby
Now save the file
next edit your default site:
$ nano /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
restart apache:
$ service apache2 restart
Page 13 of 40