works but need some cleanup

This commit is contained in:
Wojciech Todryk 2011-06-24 23:48:08 +02:00
parent 0ec83db287
commit e40a859b7d
752 changed files with 4866 additions and 27923 deletions

1
.gitignore vendored
View file

@ -4,5 +4,4 @@ config/database.yml
config/site.rb
tmp
mail_temp
config/site.rb
.svn

5
AUTHORS Normal file
View file

@ -0,0 +1,5 @@
* Luben Manolov <luben.manolov@gmail.com>
* Nick Penkov <nick.penkov@gmail.com>
* Eugene Korbut
* Emilio Blanco
* Wojciech Todryk <wojciech(at)todryk(dot).pl>

718
CHANGELOG
View file

@ -1,718 +0,0 @@
*0.14.2 (RC3)* (October 26th, 2005)
* Constants set in the development/test/production environment file are set in Object
* Scaffold generator pays attention to the controller name. #2562 [self@mattmower.com]
* Include tasks from vendor/plugins/*/tasks in the Rakefile #2545 [Rick Olson]
*0.14.1 (RC2)* (October 19th, 2005)
* Don't clean RAILS_ROOT on windows
* Remove trailing '/' from RAILS_ROOT [Nicholas Seckar]
* Upgraded to Active Record 1.12.1 and Action Pack 1.10.1
*0.14.0 (RC1)* (October 16th, 2005)
* Moved generator folder from RAILS_ROOT/generators to RAILS_ROOT/lib/generators [Tobias Luetke]
* Fix rake dev and related commands [Nicholas Seckar]
* The rails command tries to deduce your MySQL socket by running `mysql_config
--socket`. If it fails, default to /path/to/your/mysql.sock
* Made the rails command use the application name for database names in the tailored database.yml file. Example: "rails ~/projects/blog" will use "blog_development" instead of "rails_development". [Florian Weber]
* Added Rails framework freezing tasks: freeze_gems (freeze to current gems), freeze_edge (freeze to Rails SVN trunk), unfreeze_rails (float with newest gems on system)
* Added update_javascripts task which will fetch all the latest js files from your current rails install. Use after updating rails. [Tobias Luetke]
* Added cleaning of RAILS_ROOT to useless elements such as '../non-dot-dot/'. Provides cleaner backtraces and error messages. [Nicholas Seckar]
* Made the instantiated/transactional fixtures settings be controlled through Rails::Initializer. Transactional and non-instantiated fixtures are default from now on. [Florian Weber]
* Support using different database adapters for development and test with ActiveRecord::Base.schema_format = :ruby [Sam Stephenson]
* Make webrick work with session(:off)
* Add --version, -v option to the Rails command. Closes #1840. [stancell]
* Update Prototype to V1.4.0_pre11, script.aculo.us to V1.5_rc3 [2504] and fix the rails generator to include the new .js files [Thomas Fuchs]
* Make the generator skip a file if it already exists and is identical to the new file.
* Add experimental plugin support #2335
* Made Rakefile aware of new .js files in script.aculo.us [Thomas Fuchs]
* Make table_name and controller_name in generators honor AR::Base.pluralize_table_names. #1216 #2213 [kazuhiko@fdiary.net]
* Clearly label functional and unit tests in rake stats output. #2297 [lasse.koskela@gmail.com]
* Make the migration generator only check files ending in *.rb when calculating the next file name #2317 [Chad Fowler]
* Added prevention of duplicate migrations from the generator #2240 [fbeausoleil@ftml.net]
* Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file).
* Reformed all the config/environments/* files to conform to the new Rails::Configuration approach. Fully backwards compatible.
* Added create_sessions_table, drop_sessions_table, and purge_sessions_table as rake tasks for databases that supports migrations (MySQL, PostgreSQL, SQLite) to get a table for use with CGI::Session::ActiveRecordStore
* Added dump of schema version to the db_structure_dump task for databases that support migrations #1835 [Rick Olson]
* Fixed script/profiler for Ruby 1.8.2 #1863 [Rick Olson]
* Fixed clone_structure_to_test task for SQLite #1864 [jon@burningbush.us]
* Added -m/--mime-types option to the WEBrick server, so you can specify a Apache-style mime.types file to load #2059 [ask@develooper.com]
* Added -c/--svn option to the generator that'll add new files and remove destroyed files using svn add/revert/remove as appropriate #2064 [kevin.clark@gmail.com]
* Added -c/--charset option to WEBrick server, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz]
* Make the default stats task extendable by modifying the STATS_DIRECTORIES constant
* Allow the selected environment to define RAILS_DEFAULT_LOGGER, and have Rails::Initializer use it if it exists.
* Moved all the shared tasks from Rakefile into Rails, so that the Rakefile is empty and doesn't require updating.
* Added Rails::Initializer and Rails::Configuration to abstract all of the common setup out of config/environment.rb (uses config/boot.rb to bootstrap the initializer and paths)
* Fixed the scaffold generator to fail right away if the database isn't accessible instead of in mid-air #1169 [Chad Fowler]
* Corrected project-local generator location in scripts.rb #2010 [Michael Schuerig]
* Don't require the environment just to clear the logs #2093 [Scott Barron]
* Make the default rakefile read *.rake files from config/tasks (for easy extension of the rakefile by e.g. generators)
* Only load breakpoint in development mode and when BREAKPOINT_SERVER_PORT is defined.
* Allow the --toggle-spin switch on process/reaper to be negated
* Replace render_partial with render :partial in scaffold generator [Nicholas Seckar]
* Added -w flag to ps in process/reaper #1934 [Scott Barron]
* Allow ERb in the database.yml file (just like with fixtures), so you can pull out the database configuration in environment variables #1822 [Duane Johnson]
* Added convenience controls for FCGI processes (especially when managed remotely): spinner, spawner, and reaper. They reside in script/process. More details can be had by calling them with -h/--help.
* Added load_fixtures task to the Rakefile, which will load all the fixtures into the database for the current environment #1791 [Marcel Molina]
* Added an empty robots.txt to public/, so that web servers asking for it won't trigger a dynamic call, like favicon.ico #1738 [michael@schubert]
* Dropped the 'immediate close-down' of FCGI processes since it didn't work consistently and produced bad responses when it didn't. So now a TERM ensures exit after the next request (just as if the process is handling a request when it receives the signal). This means that you'll have to 'nudge' all FCGI processes with a request in order to ensure that they have all reloaded. This can be done by something like ./script/process/repear --nudge 'http://www.myapp.com' --instances 10, which will load the myapp site 10 times (and thus hit all of the 10 FCGI processes once, enough to shut down).
*0.13.1* (11 July, 2005)
* Look for app-specific generators in RAILS_ROOT/generators rather than the clunky old RAILS_ROOT/script/generators. Nobody really uses this feature except for the unit tests, so it's a negligible-impact change. If you want to work with third-party generators, drop them in ~/.rails/generators or simply install gems.
* Fixed that each request with the WEBrick adapter would open a new database connection #1685 [Sam Stephenson]
* Added support for SQL Server in the database rake tasks #1652 [ken.barker@gmail.com] Note: osql and scptxfr may need to be installed on your development environment. This involves getting the .exes and a .rll (scptxfr) from a production SQL Server (not developer level SQL Server). Add their location to your Environment PATH and you are all set.
* Added a VERSION parameter to the migrate task that allows you to do "rake migrate VERSION=34" to migrate to the 34th version traveling up or down depending on the current version
* Extend Ruby version check to include RUBY_RELEASE_DATE >= '2005-12-25', the final Ruby 1.8.2 release #1674 [court3nay@gmail.com]
* Improved documentation for environment config files #1625 [court3nay@gmail.com]
*0.13.0* (6 July, 2005)
* Changed the default logging level in config/environment.rb to INFO for production (so SQL statements won't be logged)
* Added migration generator: ./script/generate migration add_system_settings
* Added "migrate" as rake task to execute all the pending migrations from db/migrate
* Fixed that model generator would make fixtures plural, even if ActiveRecord::Base.pluralize_table_names was false #1185 [Marcel Molina]
* Added a DOCTYPE of HTML transitional to the HTML files generated by Rails #1124 [Michael Koziarski]
* SIGTERM also gracefully exits dispatch.fcgi. Ignore SIGUSR1 on Windows.
* Add the option to manually manage garbage collection in the FastCGI dispatcher. Set the number of requests between GC runs in your public/dispatch.fcgi [skaes@web.de]
* Allow dynamic application reloading for dispatch.fcgi processes by sending a SIGHUP. If the process is currently handling a request, the request will be allowed to complete first. This allows production fcgi's to be reloaded without having to restart them.
* RailsFCGIHandler (dispatch.fcgi) no longer tries to explicitly flush $stdout (CgiProcess#out always calls flush)
* Fixed rakefile actions against PostgreSQL when the password is all numeric #1462 [michael@schubert.cx]
* ActionMailer::Base subclasses are reloaded with the other rails components #1262
* Made the WEBrick adapter not use a mutex around action performance if ActionController::Base.allow_concurrency is true (default is false)
* Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron]
* Added a 'whiny nil' that's aim to ensure that when users pass nil to methods where that isn't appropriate, instead of NoMethodError? and the name of some method used by the framework users will see a message explaining what type of object was expected. Only active in test and development environments by default #1209 [Michael Koziarski]
* Fixed the test_helper.rb to be safe for requiring controllers from multiple spots, like app/controllers/article_controller.rb and app/controllers/admin/article_controller.rb, without reloading the environment twice #1390 [Nicholas Seckar]
* Fixed Webrick to escape + characters in URL's the same way that lighttpd and apache do #1397 [Nicholas Seckar]
* Added -e/--environment option to script/runner #1408 [fbeausoleil@ftml.net]
* Modernize the scaffold generator to use the simplified render and test methods and to change style from @params["id"] to params[:id]. #1367
* Added graceful exit from pressing CTRL-C during the run of the rails command #1150 [Caleb Tennis]
* Allow graceful exits for dispatch.fcgi processes by sending a SIGUSR1. If the process is currently handling a request, the request will be allowed to complete and then will terminate itself. If a request is not being handled, the process is terminated immediately (via #exit). This basically works like restart graceful on Apache. [Jamis Buck]
* Made dispatch.fcgi more robust by catching fluke errors and retrying unless its a permanent condition. [Jamis Buck]
* Added console --profile for profiling an IRB session #1154 [Jeremy Kemper]
* Changed console_sandbox into console --sandbox #1154 [Jeremy Kemper]
*0.12.1* (20th April, 2005)
* Upgraded to Active Record 1.10.1, Action Pack 1.8.1, Action Mailer 0.9.1, Action Web Service 0.7.1
*0.12.0* (19th April, 2005)
* Fixed that purge_test_database would use database settings from the development environment when recreating the test database #1122 [rails@cogentdude.com]
* Added script/benchmarker to easily benchmark one or more statement a number of times from within the environment. Examples:
# runs the one statement 10 times
script/benchmarker 10 'Person.expensive_method(10)'
# pits the two statements against each other with 50 runs each
script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)'
* Added script/profiler to easily profile a single statement from within the environment. Examples:
script/profiler 'Person.expensive_method(10)'
script/profiler 'Person.expensive_method(10)' 10 # runs the statement 10 times
* Added Rake target clear_logs that'll truncate all the *.log files in log/ to zero #1079 [Lucas Carlson]
* Added lazy typing for generate, such that ./script/generate cn == ./script/generate controller and the likes #1051 [k@v2studio.com]
* Fixed that ownership is brought over in pg_dump during tests for PostgreSQL #1060 [pburleson@gmail.com]
* Upgraded to Active Record 1.10.0, Action Pack 1.8.0, Action Mailer 0.9.0, Action Web Service 0.7.0, Active Support 1.0.4
*0.11.1* (27th March, 2005)
* Fixed the dispatch.fcgi use of a logger
* Upgraded to Active Record 1.9.1, Action Pack 1.7.0, Action Mailer 0.8.1, Action Web Service 0.6.2, Active Support 1.0.3
*0.11.0* (22th March, 2005)
* Removed SCRIPT_NAME from the WEBrick environment to prevent conflicts with PATH_INFO #896 [Nicholas Seckar]
* Removed ?$1 from the dispatch.f/cgi redirect line to get rid of 'complete/path/from/request.html' => nil being in the @params now that the ENV["REQUEST_URI"] is used to determine the path #895 [dblack/Nicholas Seckar]
* Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process
* Improved the generated scaffold code a lot to take advantage of recent Rails developments #882 [Tobias Luetke]
* Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar]
* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]
* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:
./script/runner 'ReminderService.deliver'
./script/runner 'Mailer.receive(STDIN.read)'
This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code.
* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org]
* Fixed the Rakefile's interaction with postgresql to:
1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
passwords when connecting to a remote db and local socket connections.
2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]
4. Use the port if available #875 [madrobby]
* Upgraded to Active Record 1.9.0, Action Pack 1.6.0, Action Mailer 0.8.0, Action Web Service 0.6.1, Active Support 1.0.2
*0.10.1* (7th March, 2005)
* Fixed rake stats to ignore editor backup files like model.rb~ #791 [skanthak]
* Added exception shallowing if the DRb server can't be started (not worth making a fuss about to distract new users) #779 [Tobias Luetke]
* Added an empty favicon.ico file to the public directory of new applications (so the logs are not spammed by its absence)
* Fixed that scaffold generator new template should use local variable instead of instance variable #778 [Dan Peterson]
* Allow unit tests to run on a remote server for PostgreSQL #781 [adamm@galacticasoftware.com]
* Added web_service generator (run ./script/generate web_service for help) #776 [Leon Bredt]
* Added app/apis and components to code statistics report #729 [Scott Barron]
* Fixed WEBrick server to use ABSOLUTE_RAILS_ROOT instead of working_directory #687 [Nicholas Seckar]
* Fixed rails_generator to be usable without RubyGems #686 [Cristi BALAN]
* Fixed -h/--help for generate and destroy generators #331
* Added begin/rescue around the FCGI dispatcher so no uncaught exceptions can bubble up to kill the process (logs to log/fastcgi.crash.log)
* Fixed that association#count would produce invalid sql when called sequentialy #659 [kanis@comcard.de]
* Fixed test/mocks/testing to the correct test/mocks/test #740
* Added early failure if the Ruby version isn't 1.8.2 or above #735
* Removed the obsolete -i/--index option from the WEBrick servlet #743
* Upgraded to Active Record 1.8.0, Action Pack 1.5.1, Action Mailer 0.7.1, Action Web Service 0.6.0, Active Support 1.0.1
*0.10.0* (24th February, 2005)
* Changed default IP binding for WEBrick from 127.0.0.1 to 0.0.0.0 so that the server is accessible both locally and remotely #696 [Marcel]
* Fixed that script/server -d was broken so daemon mode couldn't be used #687 [Nicholas Seckar]
* Upgraded to breakpoint 92 which fixes:
* overload IRB.parse_opts(), fixes #443
=> breakpoints in tests work even when running them via rake
* untaint handlers, might fix an issue discussed on the Rails ML
* added verbose mode to breakpoint_client
* less noise caused by breakpoint_client by default
* ignored TerminateLineInput exception in signal handler
=> quiet exit on Ctrl-C
* Added support for independent components residing in /components. Example:
Controller: components/list/items_controller.rb
(holds a List::ItemsController class with uses_component_template_root called)
Model : components/list/item.rb
(namespace is still shared, so an Item model in app/models will take precedence)
Views : components/list/items/show.rhtml
* Added --sandbox option to script/console that'll roll back all changes made to the database when you quit #672 [Jeremy Kemper]
* Added 'recent' as a rake target that'll run tests for files that changed in the last 10 minutes #612 [Jeremy Kemper]
* Changed script/console to default to development environment and drop --no-inspect #650 [Jeremy Kemper]
* Added that the 'fixture :posts' syntax can be used for has_and_belongs_to_many fixtures where a model doesn't exist #572 [Jeremy Kemper]
* Added that running test_units and test_functional now performs the clone_structure_to_test as well #566 [rasputnik]
* Added new generator framework that informs about its doings on generation and enables updating and destruction of generated artifacts. See the new script/destroy and script/update for more details #487 [Jeremy Kemper]
* Added Action Web Service as a new add-on framework for Action Pack [Leon Bredt]
* Added Active Support as an independent utility and standard library extension bundle
* Upgraded to Active Record 1.7.0, Action Pack 1.5.0, Action Mailer 0.7.0
*0.9.5* (January 25th, 2005)
* Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it.
* Added Florian Gross' latest version of Breakpointer and friends that fixes a variaty of bugs #441 [Florian Gross]
* Fixed skeleton Rakefile to work with sqlite3 out of the box #521 [rasputnik]
* Fixed that script/breakpointer didn't get the Ruby path rewritten as the other scripts #523 [brandt@kurowski.net]
* Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter
* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload
* Fixed that generate scaffold would produce bad functional tests
* Fixed that FCGI can also display SyntaxErrors
* Upgraded to Active Record 1.6.0, Action Pack 1.4.0
*0.9.4.1* (January 18th, 2005)
* Added 5-second timeout to WordNet alternatives on creating reserved-word models #501 [Marcel Molina]
* Fixed binding of caller #496 [Alexey]
* Upgraded to Active Record 1.5.1, Action Pack 1.3.1, Action Mailer 0.6.1
*0.9.4* (January 17th, 2005)
* Added that ApplicationController will catch a ControllerNotFound exception if someone attempts to access a url pointing to an unexisting controller [Tobias Luetke]
* Flipped code-to-test ratio around to be more readable #468 [Scott Baron]
* Fixed log file permissions to be 666 instead of 777 (so they're not executable) #471 [Lucas Carlson]
* Fixed that auto reloading would some times not work or would reload the models twice #475 [Tobias Luetke]
* Added rewrite rules to deal with caching to public/.htaccess
* Added the option to specify a controller name to "generate scaffold" and made the default controller name the plural form of the model.
* Added that rake clone_structure_to_test, db_structure_dump, and purge_test_database tasks now pick up the source database to use from
RAILS_ENV instead of just forcing development #424 [Tobias Luetke]
* Fixed script/console to work with Windows (that requires the use of irb.bat) #418 [octopod]
* Fixed WEBrick servlet slowdown over time by restricting the load path reloading to mod_ruby
* Removed Fancy Indexing as a default option on the WEBrick servlet as it made it harder to use various caching schemes
* Upgraded to Active Record 1.5, Action Pack 1.3, Action Mailer 0.6
*0.9.3* (January 4th, 2005)
* Added support for SQLite in the auto-dumping/importing of schemas for development -> test #416
* Added automated rewriting of the shebang lines on installs through the gem rails command #379 [Manfred Stienstra]
* Added ActionMailer::Base.deliver_method = :test to the test environment so that mail objects are available in ActionMailer::Base.deliveries
for functional testing.
* Added protection for creating a model through the generators with a name of an existing class, like Thread or Date.
It'll even offer you a synonym using wordnet.princeton.edu as a look-up. No, I'm not kidding :) [Florian Gross]
* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that
the environment options needs to change from:
Before in development.rb:
ActionController::Base.reload_dependencies = true  
ActiveRecord::Base.reload_associations     = true
Now in development.rb:
Dependencies.mechanism = :load
Before in production.rb and test.rb:
ActionController::Base.reload_dependencies = false
ActiveRecord::Base.reload_associations     = false
Now in production.rb and test.rb:
Dependencies.mechanism = :require
* Fixed problems with dependency caching and controller hierarchies on Ruby 1.8.2 in development mode #351
* Fixed that generated action_mailers doesnt need to require the action_mailer since thats already done in the environment #382 [Lucas Carlson]
* Upgraded to Action Pack 1.2.0 and Active Record 1.4.0
*0.9.2*
* Fixed CTRL-C exists from the Breakpointer to be a clean affair without error dumping [Kent Sibilev]
* Fixed "rake stats" to work with sub-directories in models and controllers and to report the code to test ration [Scott Baron]
* Added that Active Record associations are now reloaded instead of cleared to work with the new const_missing hook in Active Record.
* Added graceful handling of an inaccessible log file by redirecting output to STDERR with a warning #330 [rainmkr]
* Added support for a -h/--help parameter in the generator #331 [Ulysses]
* Fixed that File.expand_path in config/environment.rb would fail when dealing with symlinked public directories [mjobin]
* Upgraded to Action Pack 1.1.0 and Active Record 1.3.0
*0.9.1*
* Upgraded to Action Pack 1.0.1 for important bug fix
* Updated gem dependencies
*0.9.0*
* Renamed public/dispatch.servlet to script/server -- it wasn't really dispatching anyway as its delegating calls to public/dispatch.rb
* Renamed AbstractApplicationController and abstract_application.rb to ApplicationController and application.rb, so that it will be possible
for the framework to automatically pick up on app/views/layouts/application.rhtml and app/helpers/application.rb
* Added script/console that makes it even easier to start an IRB session for interacting with the domain model. Run with no-args to
see help.
* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in
the code, investigate and change the model, AND then resume execution! Example:
class WeblogController < ActionController::Base
def index
@posts = Post.find_all
breakpoint "Breaking out from the list"
end
end
So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
Here you can do things like:
Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
>> @posts.inspect
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a breakpoint"
=> "hello from a breakpoint"
...and even better is that you can examine how your runtime objects actually work:
>> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)
Finally, when you're ready to resume execution, you press CTRL-D
* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you
can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server):
SetEnv RAILS_ENV production
...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this:
ruby public/dispatcher.servlet -e production
* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that.
* Added a start_server in the root of the Rails application to make it even easier to get started
* Fixed public/.htaccess to use RewriteBase and share the same rewrite rules for all the dispatch methods
* Fixed webrick_server to handle requests in a serialized manner (the Rails reloading infrastructure is not thread-safe)
* Added support for controllers in directories. So you can have:
app/controllers/account_controller.rb # URL: /account/
app/controllers/admin/account_controller.rb # URL: /admin/account/
NOTE: You need to update your public/.htaccess with the new rules to pick it up
* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
those environments for development. This is turned on by default, but can be turned off with
ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments.
* Added support for sub-directories in app/models. So now you can have something like Basecamp with:
app/models/accounting
app/models/project
app/models/participants
app/models/settings
It's poor man's namespacing, but only for file-system organization. You still require files just like before.
Nothing changes inside the files themselves.
* Fixed a few references in the tests generated by new_mailer [Jeremy Kemper]
* Added support for mocks in testing with test/mocks
* Cleaned up the environments a bit and added global constant RAILS_ROOT
*0.8.5* (9)
* Made dev-util available to all tests, so you can insert breakpoints in any test case to get an IRB prompt at that point [Jeremy Kemper]:
def test_complex_stuff
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end
You need to install dev-utils yourself for this to work ("gem install dev-util").
* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper]
* Added the new helper style to both controller and helper templates [Jeremy Kemper]
* Added new_crud generator for creating a model and controller at the same time with explicit scaffolding [Jeremy Kemper]
* Added configuration of Test::Unit::TestCase.fixture_path to test_helper to concide with the new AR fixtures style
* Fixed that new_model was generating singular table/fixture names
* Upgraded to Action Mailer 0.4.0
* Upgraded to Action Pack 0.9.5
* Upgraded to Active Record 1.1.0
*0.8.0 (15)*
* Removed custom_table_name option for new_model now that the Inflector is as powerful as it is
* Changed the default rake action to just do testing and separate API generation and coding statistics into a "doc" task.
* Fixed WEBrick dispatcher to handle missing slashes in the URLs gracefully [alexey]
* Added user option for all postgresql tool calls in the rakefile [elvstone]
* Fixed problem with running "ruby public/dispatch.servlet" instead of "cd public; ruby dispatch.servlet" [alexey]
* Fixed WEBrick server so that it no longer hardcodes the ruby interpreter used to "ruby" but will get the one used based
on the Ruby runtime configuration. [Marcel Molina Jr.]
* Fixed Dispatcher so it'll route requests to magic_beans to MagicBeansController/magic_beans_controller.rb [Caio Chassot]
* "new_controller MagicBeans" and "new_model SubscriptionPayments" will now both behave properly as they use the new Inflector.
* Fixed problem with MySQL foreign key constraint checks in Rake :clone_production_structure_to_test target [Andreas Schwarz]
* Changed WEBrick server to by default be auto-reloading, which is slower but makes source changes instant.
Class compilation cache can be turned on with "-c" or "--cache-classes".
* Added "-b/--binding" option to WEBrick dispatcher to bind the server to a specific IP address (default: 127.0.0.1) [Kevin Temp]
* dispatch.fcgi now DOESN'T set FCGI_PURE_RUBY as it was slowing things down for now reason [Andreas Schwarz]
* Added new_mailer generator to work with Action Mailer
* Included new framework: Action Mailer 0.3
* Upgraded to Action Pack 0.9.0
* Upgraded to Active Record 1.0.0
*0.7.0*
* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures.
[Kevin Radloff]
* script/new_model now turns AccountHolder into account_holder instead of accountholder [Kevin Radloff]
* Fixed the faulty handleing of static files with WEBrick [Andreas Schwarz]
* Unified function_test_helper and unit_test_helper into test_helper
* Fixed bug with the automated production => test database dropping on PostgreSQL [dhawkins]
* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation
and can generate more than one fixture at a time. Which makes it possible for assignments like:
@people, @projects, @project_access, @companies, @accounts =
create_fixtures "people", "projects", "project_access", "companies", "accounts"
* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file)
* Upgraded to Active Record 0.9.5 (better table_name guessing, cloning, find_all_in_collection)
*0.6.5*
* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile)
* The new_model generator will now use the same rules for plural wordings as Active Record
(so Category will give categories, not categorys) [Kevin Radloff]
* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp]
* Made the GEM work with Windows
* Fixed bug where mod_ruby would "forget" the load paths added when switching between controllers
* PostgreSQL are now supported for the automated production => test database dropping [Kevin Radloff]
* Errors thrown by the dispatcher are now properly handled in FCGI.
* Upgraded to Action Pack 0.8.0 (lots and lots and lots of fixes)
* Upgraded to Active Record 0.9.4 (a bunch of fixes)
*0.6.0*
* Added AbstractionApplicationController as a superclass for all controllers generated. This class can be used
to carry filters and methods that are to be shared by all. It has an accompanying ApplicationHelper that all
controllers will also automatically have available.
* Added environments that can be included from any script to get the full Active Record and Action Controller
context running. This can be used by maintenance scripts or to interact with the model through IRB. Example:
require 'config/environments/production'
for account in Account.find_all
account.recalculate_interests
end
A short migration script for an account model that had it's interest calculation strategy changed.
* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick)
* Simplified the default Apache config so even remote requests are served off CGI as a default.
You'll now have to do something specific to activate mod_ruby and FCGI (like using the force urls).
This should make it easier for new comers that start on an external server.
* Added more of the necessary Apache options to .htaccess to make it easier to setup
* Upgraded to Action Pack 0.7.9 (lots of fixes)
* Upgraded to Active Record 0.9.3 (lots of fixes)
*0.5.7*
* Fixed bug in the WEBrick dispatcher that prevented it from getting parameters from the URL
(through GET requests or otherwise)
* Added lib in root as a place to store app specific libraries
* Added lib and vendor to load_path, so anything store within can be loaded directly.
Hence lib/redcloth.rb can be loaded with require "redcloth"
* Upgraded to Action Pack 0.7.8 (lots of fixes)
* Upgraded to Active Record 0.9.2 (minor upgrade)
*0.5.6*
* Upgraded to Action Pack 0.7.7 (multipart form fix)
* Updated the generated template stubs to valid XHTML files
* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
gives the same as "new_controller Todolists" and "new_controller todolists".
*0.5.5*
* Works on Windows out of the box! (Dropped symlinks)
* Added webrick dispatcher: Try "ruby public/dispatch.servlet --help" [Florian Gross]
* Report errors about initialization to browser (instead of attempting to use uninitialized logger)
* Upgraded to Action Pack 0.7.6
* Upgraded to Active Record 0.9.1
* Added distinct 500.html instead of reusing 404.html
* Added MIT license
*0.5.0*
* First public release

36
Gemfile Executable file
View file

@ -0,0 +1,36 @@
source 'http://rubygems.org'
gem 'rails', '3.0.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby',:require => 'sqlite3'
gem 'arel'
gem 'mysql2'
gem 'will_paginate'
gem 'web-app-theme'
gem 'tmail'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end

81
Gemfile.lock Executable file
View file

@ -0,0 +1,81 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.0.7)
actionpack (= 3.0.7)
mail (~> 2.2.15)
actionpack (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
builder (~> 2.1.2)
erubis (>= 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (>= 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.7)
activesupport (= 3.0.7)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
activesupport (3.0.7)
arel (2.0.4)
builder (2.1.2)
erubis (2.7.0)
i18n (0.5.0)
mail (2.2.18)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (>= 1.16)
treetop (>= 1.4.8)
mime-types (1.16)
mysql2 (0.2.7)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.7.3)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.7)
actionmailer (= 3.0.7)
actionpack (= 3.0.7)
activerecord (= 3.0.7)
activeresource (= 3.0.7)
activesupport (= 3.0.7)
bundler (~> 1.0)
railties (= 3.0.7)
railties (3.0.7)
actionpack (= 3.0.7)
activesupport (= 3.0.7)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
thor (0.14.6)
tmail (1.2.7.1)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
web-app-theme (0.6.3)
will_paginate (2.3.15)
PLATFORMS
ruby
DEPENDENCIES
arel
mysql2
rails (= 3.0.7)
sqlite3-ruby
tmail
web-app-theme
will_paginate

View file

@ -1,23 +0,0 @@
Copyright (c) 2005, 2006 VibrantPlanet Ltd.
Copyright (c) 2005, 2006 Luben Manolov
Copyright (c) 2005, 2006 Nick Penkov
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

34
README
View file

@ -1,34 +0,0 @@
Installation Guide
Requirements
* Ruby 1.8.7
* Rails 2.3.2
Installation
1. Checkout the source code
2. If you need to override some of the default constants used in the application take a look at config/default_site.rb. Then create config/site.rb that contains only the keys which you want to override. Example content of config/site.rb is:
module CDF
LOCALCONFIG = {
:imap_server => 'your.imap.server'
}
end
3. Configure SMTP settings
# initializers/smtp_settings.rb
ActionMailer::Base.smtp_settings = {
:address => "mail.example.com.py",
:port => 26,
:authentication => :plain,
:enable_starttls_auto => true,
:user_name => "emilio@example.com.py",
:password => "yourpass"
}
4. Prepare config/database.yml file (see config/database.yml.example)
5. Migrate database (rake db:migrate)
6. Use it

40
README.markdown Executable file
View file

@ -0,0 +1,40 @@
## Introduction
_Mailr_ is a IMAP mail client based on _Ruby on Rails_ platform.
## Installation guide
**NOTE** All path and filenames are based on _Rails.root_ directory.
### Requirements
In _Rails 3_ all dependencies should be defined in file _<Rails.root>.Gemfile_. All needed gems can be installed using bundler.
### Installation procedure
1. Checkout the source code.
2. If you need to override some of the default constants used in the application take a look at config/default_site.rb. Then create config/site.rb that contains only the keys which you want to override. Example content of config/site.rb is:
module CDF
LOCALCONFIG = {
:imap_server => 'your.imap.server'
}
end
3. Configure SMTP settings
# initializers/smtp_settings.rb
ActionMailer::Base.smtp_settings = {
:address => "mail.example.com.py",
:port => 26,
:authentication => :plain,
:enable_starttls_auto => true,
:user_name => "emilio@example.com.py",
:password => "yourpass"
}
4. Prepare config/database.yml file (see config/database.yml.example).
Check if proper gems (sqlite3/mysql/postgresql) are defined in _Gemfile_ and installed.
5. Migrate database (rake db:migrate)
6. Use it.

9
Rakefile Normal file → Executable file
View file

@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
Rails3::Application.load_tasks

24
UNLICENSE Normal file
View file

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

43
app/controllers/application_controller.rb Normal file → Executable file
View file

@ -1,34 +1,43 @@
# The filters added to this controller will be run for all controllers in the application.
# Likewise will all the methods added be available for all controllers.
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :user_login_filter
before_filter :add_scripts
#before_filter :localize
filter_parameter_logging :password
#filter_parameter_logging :password #upgrade to Rails3
protected
def secure_user?() true end
def secure_cust?() false end
def additional_scripts() "" end
def onload_function() "" end
private
def add_scripts
@additional_scripts = additional_scripts()
@onload_function = onload_function()
end
def user_login_filter
if (secure_user? or secure_cust? )and logged_user.nil?
session["return_to"] = request.request_uri
#upgrade Rails 3
#session["return_to"] = request.request_uri
logger.debug "*** return_to => #{request.fullpath}"
session["return_to"] = request.fullpath
redirect_to :controller=>"/login", :action => "index"
return false
end
end
alias login_required user_login_filter
alias login_required user_login_filter
def logged_user # returns customer id
session['user']
end
@ -36,7 +45,7 @@ class ApplicationController < ActionController::Base
def logged_customer
session['user']
end
def localize
# We will use instance vars for the locale so we can make use of them in
# the templates.
@ -65,7 +74,7 @@ class ApplicationController < ActionController::Base
end
public
def include_tinymce(mode="textareas",elements="")
tinymce=''
tinymce << '
@ -76,11 +85,11 @@ class ApplicationController < ActionController::Base
tinymce << mode << '",'
if mode == "exact"
tinymce << 'elements : "' << elements << '",
'
'
end
tinymce << '
theme : "advanced",
cleanup : true,
cleanup : true,
width: "100%",
remove_linebreaks : false,
entity_encoding : "named",
@ -142,25 +151,25 @@ class ApplicationController < ActionController::Base
</script>'
tinymce
end
helper_method :include_tinymce
def include_simple_tinymce(mode="textareas",elements="")
tinymce = ''
tinymce << '<script language="javascript" type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "'
tinymce << mode << '",'
if mode == "exact"
tinymce << 'elements : "' << elements << '",
'
'
end
tinymce << '
theme : "default",
width : "100%",
auto_reset_designmode : true
});
});
</script>'
tinymce
end
@ -168,7 +177,7 @@ class ApplicationController < ActionController::Base
def _(text)
t text
end
helper_method :include_simple_tinymce, :_

0
app/controllers/contact_groups_controller.rb Normal file → Executable file
View file

0
app/controllers/contacts_controller.rb Normal file → Executable file
View file

0
app/controllers/folders_controller.rb Normal file → Executable file
View file

38
app/controllers/login_controller.rb Normal file → Executable file
View file

@ -1,14 +1,16 @@
require 'ezcrypto'
require 'imapmailbox'
class LoginController < ApplicationController
def index
if not(logged_user.nil?)
redirect_to :controller =>"webmail", :action=>"index"
redirect_to :controller =>"webmail", :action=>"index"
else
@login_user = Customer.new
end
end
end
def authenticate
if user = auth(params['login_user']["email"], params['login_user']["password"])
session["user"] = user.id
@ -17,26 +19,27 @@ class LoginController < ApplicationController
else
# dont use crypt
session["wmp"] = params['login_user']["password"]
end
end
if session["return_to"]
redirect_to(session["return_to"])
session["return_to"] = nil
else
redirect_to :action=>"index"
redirect_to :action=>"index"
end
else
logger.debug "*** Not logged"
@login_user = Customer.new
flash["error"] = t :wrong_email_or_password
redirect_to :action => "index"
redirect_to :action => "index"
end
end
def logout
reset_session
flash["status"] = t(:user_logged_out)
redirect_to :action => "index"
redirect_to :action => "index"
end
protected
def need_subdomain?() true end
@ -45,12 +48,15 @@ class LoginController < ApplicationController
private
def auth(email, password)
mailbox = IMAPMailbox.new
mailbox = IMAPMailbox.new(Rails.logger)
logger.info "*** mailbox #{mailbox.inspect}"
begin
mailbox.connect(email, password)
rescue
return nil
mailbox.connect(email, password)
rescue Exception => exc
logger.debug "*** auth/Mailbox Object => #{exc.message}"
return nil
end
mailbox.disconnect
mailbox = nil
if user = Customer.find_by_email(email)
@ -60,6 +66,6 @@ class LoginController < ApplicationController
user = Customer.create("email"=>email)
MailPref.create('customer_id' => user.id)
return user
end
end
end
end
end

175
app/controllers/webmail_controller.rb Normal file → Executable file
View file

@ -3,58 +3,63 @@ require 'net/smtp'
require 'net/imap'
require 'mail2screen'
require 'ezcrypto'
require 'imapmailbox'
require 'imap_utils'
class WebmailController < ApplicationController
include ImapUtils
logger.info "*** WebmailController #{logger.inspect}"
# Administrative functions
before_filter :login_required
before_filter :obtain_cookies_for_search_and_nav, :only=>[:messages]
before_filter :load_imap_session
after_filter :close_imap_session
layout "public", :except => [:view_source, :download]
# model :filter, :expression, :mail_pref, :customer
BOOL_ON = "on"
def index
redirect_to(:action=>"messages")
end
def error_connection
end
def refresh
@mailbox.reload
@folders = @mailbox.folders
redirect_to(:action=>'messages')
end
def messages
session["return_to"] = nil
@search_field = params['search_field']
@search_value = params['search_value']
# handle sorting - tsort session field contains last reverse or no for field
# and lsort - last sort field
if session['tsort'].nil? or session['lsort'].nil?
session['lsort'] = "DATE"
session['tsort'] = {"DATE" => true, "FROM" => true, "SUBJECT" => true, "TO" => false}
end
case operation_param
when t(:copy) # copy
msg_ids = []
messages_param.each { |msg_id, bool|
messages_param.each { |msg_id, bool|
msg_ids << msg_id.to_i if bool == BOOL_ON and dst_folder != @folder_name } if messages_param
folder.copy_multiple(msg_ids, dst_folder) if msg_ids.size > 0
folder.copy_multiple(msg_ids, dst_folder) if msg_ids.size > 0
when t(:move) # move
msg_ids = []
messages_param.each { |msg_id, bool|
messages_param.each { |msg_id, bool|
msg_ids << msg_id.to_i if bool == BOOL_ON and dst_folder != @folder_name } if messages_param
folder.move_multiple(msg_ids, dst_folder) if msg_ids.size > 0
folder.move_multiple(msg_ids, dst_folder) if msg_ids.size > 0
when t(:delete) # delete
msg_ids = []
messages_param.each { |msg_id, bool| msg_ids << msg_id.to_i if bool == BOOL_ON } if messages_param
@ -67,10 +72,10 @@ class WebmailController < ApplicationController
session['lsort'] = sort_query = params["scc"]
session['tsort'][sort_query] = (session['tsort'][sort_query]? false : true)
@search_field, @search_value = session['search_field'], session['search_value']
when t(:search) # search
when t(:search) # search
session['search_field'] = @search_field
session['search_value'] = @search_value
when t(:show_all) # search
when t(:show_all) # search
session['search_field'] = @search_field = nil
session['search_value'] = @search_value = nil
else
@ -78,7 +83,7 @@ class WebmailController < ApplicationController
@search_field = session['search_field']
@search_value = session['search_value']
end
sort_query = session['lsort']
reverse_sort = session['tsort'][sort_query]
query = ["ALL"]
@ -92,39 +97,39 @@ class WebmailController < ApplicationController
@pages = Paginator.new self, folder.total, get_mail_prefs.wm_rows, @page
@messages = folder.messages(@pages.current.first_item - 1, get_mail_prefs.wm_rows, sort_query + (reverse_sort ? ' desc' : ' asc'))
end
end
def delete
@msg_id = msg_id_param.to_i
folder.delete(@msg_id)
redirect_to(:action=>"messages")
end
def reply # not ready at all
@msg_id = msg_id_param.to_i
@imapmail = folder.message(@msg_id)
fb = @imapmail.full_body
@tmail = TMail::Mail.parse(fb)
@tmail = TMail::Mail.parse(fb)
@mail = prepare_mail
@mail.reply(@tmail, fb, get_mail_prefs.mail_type)
render :action => 'compose'
end
def forward
@msg_id = msg_id_param.to_i
@imapmail = folder.message(@msg_id)
fb = @imapmail.full_body
@tmail = TMail::Mail.parse(fb)
@tmail = TMail::Mail.parse(fb)
@mail = prepare_mail
@mail.forward(@tmail, fb)
render :action => 'compose'
end
def compose
if @mail.nil?
operation = operation_param
@ -133,13 +138,13 @@ class WebmailController < ApplicationController
encmail = @mail.send_mail
get_imap_session
@mailbox.message_sent(encmail)
# delete temporary files (attachments)
@mail.delete_attachments()
render :action => :mailsent
elsif operation == t(:add)
@mail = create_mail
if params['attachment']
if params['attachment']
attachment = CDF::Attachment.new(@mail)
attachment.file = params['attachment']
end
@ -149,7 +154,7 @@ class WebmailController < ApplicationController
end
end
end
def empty # empty trash folder (works for any one else :-))
folder.messages(0, -1).each{ |message|
folder.delete(message)
@ -157,50 +162,50 @@ class WebmailController < ApplicationController
folder.expunge
redirect_to(:action=>"messages")
end
def message
@msg_id = msg_id_param
@imapmail = folder.message(@msg_id)
folder.mark_read(@imapmail.uid) if @imapmail.unread
@mail = TMail::Mail.parse(@imapmail.full_body)
end
def download
msg_id = msg_id_param
imapmail = folder.message(msg_id)
mail = TMail::Mail.parse(imapmail.full_body)
mail = TMail::Mail.parse(imapmail.full_body)
if mail.multipart?
get_parts(mail).each { |part|
return send_part(part) if part.header and part.header['content-type']['name'] == params['ctype']
get_parts(mail).each { |part|
return send_part(part) if part.header and part.header['content-type']['name'] == params['ctype']
}
render("webmail/noattachment")
else
else
render("webmail/noattachment")
end
end
end
def prefs
@customer = Customer.find(logged_customer)
@mailpref = MailPref.find_or_create_by_customer_id logged_customer
if params['op'] == _('Save')
if params['customer']
@customer.fname = params['customer']['fname']
@customer.lname = params['customer']['lname']
@customer.save
end
@mailpref.attributes = params["mailpref"]
@mailpref.attributes = params["mailpref"]
@mailpref.save
session["wmimapseskey"] = nil
redirect_to(:action=>"messages")
end
end
# Message filters management
def filters
end
def filter
if params['op']
@filter = Filter.new(params['filter'])
@ -209,7 +214,7 @@ class WebmailController < ApplicationController
case params['op']
when _('Add')
@filter.expressions << Expression.new
when _('Save')
when _('Save')
if params['filter']['id'] and params['filter']['id'] != ""
@sf = Filter.find(params['filter']['id'])
@sf.name, @sf.destination_folder = @filter.name, @filter.destination_folder
@ -228,11 +233,11 @@ class WebmailController < ApplicationController
@expressions = @filter.expressions
else
@filter = Filter.find(params["id"]) if params["id"]
@expressions = @filter.expressions
@expressions = @filter.expressions
end
@destfolders = get_to_folders
end
def filter_delete
Filter.delete(params["id"])
# reindex other filters
@ -246,7 +251,7 @@ class WebmailController < ApplicationController
@user.serialize_to_file
redirect_to :action=>"filters"
end
def filter_up
filt = @user.filters.find(params['id'])
ufilt = @user.filters.find_all("order_num = #{filt.order_num - 1}").first
@ -257,7 +262,7 @@ class WebmailController < ApplicationController
@user.serialize_to_file
redirect_to :action=>"filters"
end
def filter_down
filt = Filter.find(params["id"])
dfilt = @user.filters[filt.order_num]
@ -268,7 +273,7 @@ class WebmailController < ApplicationController
@user.serialize_to_file
redirect_to :action=>"filters"
end
def filter_add
@filter = Filter.new
@filter.expressions << Expression.new
@ -277,58 +282,58 @@ class WebmailController < ApplicationController
render "filter"
end
# end of filters
def view_source
@msg_id = msg_id_param.to_i
@imapmail = folder.message(@msg_id)
@msg_source = CGI.escapeHTML(@imapmail.full_body).gsub("\n", "<br/>")
end
def auto_complete_for_mail_to
auto_complete_responder_for_contacts params[:mail][:to]
end
def auto_complete_for_mail_cc
auto_complete_responder_for_contacts params[:mail][:cc]
end
def auto_complete_for_mail_bcc
auto_complete_responder_for_contacts params[:mail][:bcc]
end
private
def auto_complete_responder_for_contacts(value)
# first split by "," and take last name
searchName = value.split(',').last.strip
# if there are 2 names search by them
if searchName.split.size > 1
fname, lname = searchName.split.first, searchName.split.last
conditions = ['customer_id = ? and LOWER(fname) LIKE ? and LOWER(lname) like ?', logged_customer, fname.downcase + '%', lname.downcase + '%']
else
conditions = ['customer_id = ? and LOWER(fname) LIKE ?', logged_customer, searchName.downcase + '%']
end
end
@contacts = Contact.find(:all, :conditions => conditions, :order => 'fname ASC',:limit => 8)
render :partial => 'contacts'
end
protected
def additional_scripts()
@additional_css = ["webmail/webmail"]
@additional_js = ["webmail"]
end
private
def get_to_folders
res = Array.new
@folders.each{|f| res << f unless f.name == CDF::CONFIG[:mail_sent] or f.name == CDF::CONFIG[:mail_inbox] }
res
end
def create_mail
m = CDF::Mail.new(user.mail_temporary_path)
if params["mail"]
@ -343,24 +348,24 @@ class WebmailController < ApplicationController
end
else
m.from, m.content_type = user.friendlly_local_email, get_mail_prefs.mail_type
end
end
m.customer_id = logged_customer
m
end
def prepare_mail
m = CDF::Mail.new(user.mail_temporary_path)
m.from, m.content_type = user.friendlly_local_email, get_mail_prefs.mail_type
m
end
def send_part(part)
if part.content_type == "text/html"
disposition = "inline"
elsif part.content_type.include?("image/")
disposition = "inline"
else
disposition = "inline"
else
disposition = "attachment"
end
headers['Content-Length'] = part.body.size
@ -369,48 +374,48 @@ class WebmailController < ApplicationController
headers['Content-Disposition'] = disposition << %(; filename="#{part.header['content-type']['name']}")
render :text => part.body
end
def get_parts(mail)
parts = Array.new
parts << mail
mail.parts.each { |part|
mail.parts.each { |part|
if part.multipart?
parts = parts.concat(get_parts(part))
parts = parts.concat(get_parts(part))
elsif part.content_type and part.content_type.include?("rfc822")
parts = parts.concat(get_parts(TMail::Mail.parse(part.body))) << part
else
else
parts << part
end
}
parts
}
parts
end
def obtain_cookies_for_search_and_nav
@srch_class = ((cookies['_wmlms'] and cookies['_wmlms'] == 'closed') ? 'closed' : 'open')
@srch_img_src = ((cookies['_wmlms'] and cookies['_wmlms'] == 'closed') ? 'closed' : 'opened')
@srch_img_src = ((cookies['_wmlms'] and cookies['_wmlms'] == 'closed') ? 'closed' : 'opened')
@ops_class = ((cookies['_wmlmo'] and cookies['_wmlmo'] == 'closed') ? 'closed' : 'open')
@ops_img_src = ((cookies['_wmlmo'] and cookies['_wmlmo'] == 'closed') ? 'closed' : 'opened')
end
@ops_img_src = ((cookies['_wmlmo'] and cookies['_wmlmo'] == 'closed') ? 'closed' : 'opened')
end
###################################################################
### Some fixed parameters and session variables
###################################################################
def folder
@folders[@folder_name]
end
def msg_id_param
params["msg_id"]
end
def messages_param
params["messages"]
end
def dst_folder
params["cpdest"]
end
def operation_param
params["op"]
end

0
app/helpers/application_helper.rb Normal file → Executable file
View file

0
app/helpers/contact_group_helper.rb Normal file → Executable file
View file

0
app/helpers/contacts_helper.rb Normal file → Executable file
View file

0
app/helpers/folders_helper.rb Normal file → Executable file
View file

0
app/helpers/navigation_helper.rb Normal file → Executable file
View file

63
app/helpers/webmail_helper.rb Normal file → Executable file
View file

@ -6,35 +6,35 @@ module WebmailHelper
def link_compose_new
link_to(t(:compose_txt), :controller=>"webmail", :action=>"compose")
end
def link_refresh
link_to(t(:refresh), :controller=>"webmail", :action=>"refresh")
end
def link_message_list
link_to(_('Message list'), :controller=>"webmail", :action=>"messages")
end
def link_reply_to_sender(msg_id)
link_to(t(:reply), :controller=>"webmail", :action=>"reply", :params=>{"msg_id"=>msg_id})
end
def link_forward_message(msg_id)
link_to(t(:forward), :controller=>"webmail", :action=>"forward", :params=>{"msg_id"=>msg_id})
end
def link_flag_for_deletion(msg_id)
link_to(t(:delete), :controller=>"webmail", :action=>"delete", :params=>{"msg_id"=>msg_id})
end
def link_view_source(msg_id)
link_to(t(:view_source), {:controller=>"webmail", :action=>"view_source", :params=>{"msg_id"=>msg_id}}, {'target'=>"_blank"})
end
def link_filter_add
link_to(t(:add_filter), :controller=>'webmail', :action=>'filter_add')
end
def folder_link(folder)
return folder.name if folder.attribs.include?(:Noselect)
folder_name = short_fn(folder)
@ -42,7 +42,8 @@ module WebmailHelper
title = folder.unseen > 0 ? "#{folder_name} (#{folder.unseen})" : "#{folder_name}"
link = link_to title, :controller => 'webmail', :action => 'messages', :folder_name => folder.name
link = content_tag('b', link) if folder.name == @folder_name
link += '&nbsp;' + empty_trash_link(folder.name) if folder.trash?
link += raw('&nbsp;' + empty_trash_link(folder.name)) if folder.trash?
logger.info link
link
end
@ -58,7 +59,7 @@ module WebmailHelper
d.strftime("%H:%M")
else
d.strftime("%Y-%m-%d")
end
end
rescue
begin
d = imap2time(datestr)
@ -66,43 +67,43 @@ module WebmailHelper
d.strftime("%H:%M")
else
d.strftime("%Y-%m-%d")
end
end
rescue
datestr
end
end
end
def attachment(att, index)
ret = "#{att.filename}"
# todo: add link to delete attachment
#ret <<
#ret <<
ret << "<input type='hidden' name='att_files[#{index}]' value='#{att.filename}'/>"
ret << "<input type='hidden' name='att_tfiles[#{index}]' value='#{att.temp_filename}'/>"
ret << "<input type='hidden' name='att_ctypes[#{index}]' value='#{att.content_type}'/>"
end
def link_filter_up(filter_id)
link_to(_('Up'), :controller=>"webmail", :action=>"filter_up", :id=>filter_id)
end
def link_filter_down(filter_id)
link_to(_('Down'), :controller=>"webmail", :action=>"filter_down", :id=>filter_id)
end
def link_filter_edit(filter_id)
link_to(_('Edit'), :controller=>"webmail", :action=>"filter", :id=>filter_id)
end
def link_filter_delete(filter_id)
link_to(_('Delete'), :controller=>"webmail", :action=>"filter_delete", :id=>filter_id)
end
def page_navigation_webmail(pages)
nav = "<p class='paginator'><small>"
nav << "(#{pages.length} #{t :pages}) &nbsp; "
window_pages = pages.current.window.pages
nav << "..." unless window_pages[0].first?
for page in window_pages
@ -114,27 +115,27 @@ module WebmailHelper
end
nav << "..." unless window_pages[-1].last?
nav << " &nbsp; "
nav << link_to(t(:first), :controller=>"webmail", :action=>'messages', :page=>@pages.first.number) << " | " unless @pages.current.first?
nav << link_to(t(:prev), :controller=>"webmail", :action=>'messages', :page=>@pages.current.previous.number) << " | " if @pages.current.previous
nav << link_to(t(:next), :controller=>"webmail", :action=>'messages', :page=>@pages.current.next.number) << " | " if @pages.current.next
nav << link_to(t(:last), :controller=>"webmail", :action=>'messages', :page=>@pages.last.number) << " | " unless @pages.current.last?
nav << "</small></p>"
return nav
end
def parse_subject(subject)
begin
if mime_encoded?(subject)
if mime_decode(subject) == ''
if mime_decode(subject) == ''
_('(No subject)')
else
mime_decode(subject)
end
else
if from_qp(subject) == ''
if from_qp(subject) == ''
_('(No subject)')
else
from_qp(subject)
@ -143,17 +144,17 @@ module WebmailHelper
rescue Exception => ex
RAILS_DEFAULT_LOGGER.debug('Exception occured - #{ex}')
return ""
end
end
end
def message_size(size)
def message_size(size)
if size / (1024*1024) > 0
return "#{(size / (1024*1024)).round}&nbsp;MB"
elsif size / 1024 > 0
elsif size / 1024 > 0
return "#{(size / (1024)).round}&nbsp;KB"
else
return "#{size}&nbsp;B"
end
end
end
private
@ -161,6 +162,6 @@ module WebmailHelper
def empty_trash_link(folder_name)
link_to( "(#{t :empty})",
{ :controller => "webmail", :action => "empty", :params=>{"folder_name"=>folder_name}},
:confirm => t(:want_to_empty_trash_message))
:confirm => t(:want_to_empty_trash_message))
end
end

71
app/models/contact.rb Normal file → Executable file
View file

@ -1,34 +1,37 @@
require 'cdfutils'
require_association 'contact_group'
class Contact < ActiveRecord::Base
class Contact < ActiveRecord::Base
validate :check_fname_and_lname, :check_mail_cannot_be_changed
validate :check_email, :on => :create
has_and_belongs_to_many :groups, :class_name => "ContactGroup", :join_table => "contact_contact_groups", :association_foreign_key => "contact_group_id", :foreign_key => "contact_id"
# Finder methods follow
def Contact.find_by_user(user_id)
find(:all, :conditions => ["customer_id = ?", user_id], :order => "fname asc", :limit => 10)
end
def Contact.find_by_user_email(user_id, email)
find(:first, :conditions => ["customer_id = #{user_id} and email = ?", email])
end
def Contact.find_by_group_user(user_id, grp_id)
result = Array.new
find(:all, :conditions => ["customer_id = ?", user_id], :order => "fname asc").each { |c|
begin
begin
c.groups.find(grp_id)
result << c
result << c
rescue ActiveRecord::RecordNotFound
end
}
result
end
named_scope :for_customer, lambda{ |customer_id| {:conditions => {:customer_id => customer_id}} }
named_scope :letter, lambda{ |letter| {:conditions => ["contacts.fname LIKE ?", "#{letter}%"]} }
scope :for_customer, lambda{ |customer_id| {:conditions => {:customer_id => customer_id}} }
scope :letter, lambda{ |letter| {:conditions => ["contacts.fname LIKE ?", "#{letter}%"]} }
def Contact.find_by_user_letter(user_id, letter)
find_by_sql("select * from contacts where customer_id=#{user_id} and substr(UPPER(fname),1,1) = '#{letter}' order by fname")
end
@ -36,36 +39,38 @@ class Contact < ActiveRecord::Base
def full_name
"#{fname}&nbsp;#{lname}"
end
def show_name
"#{fname} #{lname}"
end
def full_address
"#{fname} #{lname}<#{email}>"
end
protected
def validate
errors.add 'fname', I18n.t(:validate_fname_error) unless self.fname =~ /^.{2,20}$/i
errors.add 'lname', I18n.t(:validate_lname_error) unless self.lname =~ /^.{2,20}$/i
# Contact e-mail cannot be changed
unless self.new_record?
protected
def check_fname_and_lname
errors.add 'fname', t(:validate_fname_error) unless self.fname =~ /^.{2,20}$/i
errors.add 'lname', t(:validate_lname_error) unless self.lname =~ /^.{2,20}$/i
end
def check_mail_cannot_be_changed
# Contact e-mail cannot be changed
unless self.new_record?
old_record = Contact.find(self.id)
errors.add 'email', I18n.t(:contacto_cannot_be_changed) unless old_record.email == self.email
errors.add 'email', t(:contact_cannot_be_changed) unless old_record.email == self.email
end
end
def check_mail
# Contact e-mail cannot be changed, so we only need to validate it on create
errors.add 'email', t(:validate_email_error) unless valid_email?(self.email)
# Already existing e-mail in contacts for this user is not allowed
if self.new_record?
if Contact.find :first, :conditions => {:email => email, :customer_id => customer_id}
errors.add('email', I18n.t(:email_exists))
end
end
end
def validate_on_create
# Contact e-mail cannot be changed, so we only need to validate it on create
errors.add 'email', I18n.t(:validate_email_error) unless valid_email?(self.email)
# Already existing e-mail in contacts for this user is not allowed
if self.new_record?
if Contact.find :first, :conditions => {:email => email, :customer_id => customer_id}
errors.add('email', I18n.t(:email_exists))
end
end
end
end

43
app/models/contact_group.rb Normal file → Executable file
View file

@ -1,25 +1,30 @@
class ContactGroup < ActiveRecord::Base
has_and_belongs_to_many :contacts, :class_name => "Contact", :join_table => "contact_contact_groups", :association_foreign_key => "contact_id", :foreign_key => "contact_group_id"
has_and_belongs_to_many :contacts, :class_name => "Contact", :join_table => "contact_contact_groups", :association_foreign_key => "contact_id", :foreign_key => "contact_group_id"
validate :check_group_name
validate :check_group_id, :on => :create
validate :check_group_uniqness, :on => :update
def ContactGroup.find_by_user(user_id)
find_by_sql("select * from contact_groups where customer_id = #{user_id} order by name asc")
end
protected
def validate
errors.add('name', :contactgroup_name_invalid) unless self.name =~ /^.{1,50}$/i
def ContactGroup.find_by_user(user_id)
find_by_sql("select * from contact_groups where customer_id = #{user_id} order by name asc")
end
def validate_on_create
if ContactGroup.find_first(["name = '#{name}' and customer_id = #{user_id}"])
errors.add("name", _('Please enter group name (1 to 50 characters)'))
end
protected
def check_group_name
errors.add('name', t(:contactgroup_name_invalid)) unless self.name =~ /^.{1,50}$/i
end
def check_group_id
if ContactGroup.find_first(["name = '#{name}' and customer_id = #{user_id}"])
errors.add("name", _('Please enter group name (1 to 50 characters)'))
end
end
def validate_on_update
if ContactGroup.find_first(["name = '#{name}' and customer_id = #{user_id} and id <> #{id}"])
errors.add("name", _('You already have contact group with this name'))
end
def check_group_uniqness
if ContactGroup.find_first(["name = '#{name}' and customer_id = #{user_id} and id <> #{id}"])
errors.add("name", _('You already have contact group with this name'))
end
end
end

0
app/models/customer.rb Normal file → Executable file
View file

0
app/models/mail_pref.rb Normal file → Executable file
View file

0
app/views/contact_groups/index.html.erb Normal file → Executable file
View file

View file

0
app/views/contacts/index.html.erb Normal file → Executable file
View file

20
app/views/contacts/new.html.erb Normal file → Executable file
View file

@ -20,24 +20,24 @@
<div id="tab_content">
<% form_tag( contacts_path, 'method' => 'post', 'class' => 'two_columns') do %>
<%= form_tag( contacts_path, 'method' => 'post', 'class' => 'two_columns') do %>
<%= form_input(:hidden_field, 'contact', 'id') %>
<%= form_input(:hidden_field, 'contact', 'customer_id') %>
<table>
<%= form_input(:text_field, 'contact', 'fname', t(:first_name), 'class'=>'two_columns') %>
<%= form_input(:text_field, 'contact', 'lname', t(:last_name), 'class'=>'two_columns') %>
<%= form_input((@contact.new_record? ? :text_field : :read_only_field), 'contact', 'email', t(:email), 'class'=>'two_columns')%>
</table>
<% for group in @contactgroups %>
<input id="groups[<%=group.id%>]" type="hidden" name="groups[<%=group.id%>]" value="<%=@groups[group.id]%>">
<% end %>
<% end %>
<% if not(@contactgroups.empty?) %>
<%=_('Contact belong to these groups')%>:
<table class="list">
<tr>
<%
<%
end
col = 1
for group in @contactgroups %>
@ -57,17 +57,17 @@
<% end %>
<% if not(@contactgroups.empty?) %>
</tr>
</table>
</table>
<% end %>
<table class="edit">
<table class="edit">
<tr>
<td colspan=2 class="buttonBar">
<input type="submit" name="paction" value="<%=t(:save)%>"/>
<input type="submit" name="paction" value="<%=t(:save_and_add_another)%>"/>
</td>
</tr>
</table>
</tr>
</table>
<% end %>
</div>
</div>

8
app/views/folders/index.html.erb Normal file → Executable file
View file

@ -15,18 +15,18 @@
<div id="tab_main">
<div id="tab_content">
<% content_for('sidebar') { %>
<% content_for('sidebar') { %>
<div id="folders">
<h4><%= t :add_folder %></h4>
<hr/>
<% form_tag folders_path, :id => 'new_folder' do %>
<%= form_tag folders_path, :id => 'new_folder' do %>
<ul>
<li><label for='folder'><%= t :name %>:</label></li>
<li><%= text_field_tag 'folder', '', :size => 18 %></li>
<li><%= submit_tag t(:add_folder) %></li>
</ul>
<% end %>
</div>
</div>
<% } %>
<div id="messages">
@ -45,4 +45,4 @@
</div>
</div>
</div>
</div>
</div>

0
app/views/layouts/chooser.html.erb Normal file → Executable file
View file

0
app/views/layouts/login.html.erb Normal file → Executable file
View file

5
app/views/layouts/public.html.erb Normal file → Executable file
View file

@ -14,7 +14,10 @@
<div id="wholepage">
<div id="container">
<div id="sidebar_outer">
<div id="sidebar"><%= yield :sidebar %></div>
<div id="logo"></div>
<div id="sidebar">
<%= yield :sidebar %>
</div>
</div>
<div id="content"><%= yield %></div>
<br class="clear"/>

0
app/views/login/index.rhtml Normal file → Executable file
View file

4
app/views/shared/_folders.html.erb Normal file → Executable file
View file

@ -3,8 +3,8 @@
<hr/>
<ul>
<% @folders.each do |folder| -%>
<li><%= folder_link(folder) %></li>
<% end -%>
<li><%= raw folder_link(folder) %></li>
<% end -%>
</ul>
</div>
<div style="text-align: center; padding: 10px;">

View file

View file

View file

View file

View file

View file

View file

View file

View file

@ -15,9 +15,9 @@
<div id="tab_main">
<div id="tab_content">
<% content_for('sidebar') { %>
<%= render :partial => 'shared/folders' %>
<% } %>
<% content_for :sidebar do %>
<%= render :partial => 'shared/folders' %>
<% end %>
<div id="messages">
<div id="msglist">
@ -25,11 +25,11 @@
<%= form_tag({:controller=>'webmail', :action=>'messages'})%>
<div class='notviscode'><input type="submit" name="op" value="<%= t :search %>" /></div>
<input type="hidden" name="page" value="<%=@page%>"/>
<a href='#' onclick='toggle_msg_operations(true);'>
<%=t :operations%><img id='img_msgops' alt='open' src='../images/list_<%=@ops_img_src%>.gif'/>
</a>
<div id="msgops" class='<%=@ops_class%>'>
<h4><%= t :operations_txt %></h4>
<span id="opch">

View file

BIN
arts/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
arts/logo.xcf Executable file

Binary file not shown.

4
config.ru Executable file
View file

@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails3::Application

63
config/application.rb Executable file
View file

@ -0,0 +1,63 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Rails3
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths << Rails.root.join("vendor/ezcrypto-0.1.1/lib")
config.autoload_paths << Rails.root.join("lib/webmail")
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
#config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
#config.i18n.default_locale = :en
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
default_config_path = 'config/default_site'
default_config = Rails.root.join(default_config_path)
require default_config
begin
require Rails.root.join("config/site")
CDF::CONFIG.update(CDF::LOCALCONFIG) if CDF::LOCALCONFIG
rescue LoadError
STDERR.puts 'WARNING: config/site.rb not found, using default settings from ' + default_config_path
end
#if CONFIG[:locale] is nil then I18n.default_locale will be used
config.i18n.default_locale = CDF::CONFIG[:locale]
require 'tmail_patch'
$KCODE = 'u'
require 'jcode'
end
end

111
config/boot.rb Normal file → Executable file
View file

@ -1,109 +1,6 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
require 'rubygems'
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end
# All that for this:
Rails.boot!
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

0
config/default_site.rb Normal file → Executable file
View file

84
config/environment.rb Normal file → Executable file
View file

@ -1,81 +1,5 @@
# Be sure to restart your webserver when you modify this file.
# Load the rails application
require File.expand_path('../application', __FILE__)
# Uncomment below to force Rails into production mode
# (Use only when you can't set environment variables through your web/app server)
# ENV['RAILS_ENV'] = 'production'
#RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Skip frameworks you're not going to use
# config.frameworks -= [ :action_web_service, :action_mailer ]
# Add additional load paths for your own custom dirs
config.load_paths += %W( #{RAILS_ROOT}/vendor/ezcrypto-0.1.1/lib )
config.load_paths += %W( #{RAILS_ROOT}/lib/webmail )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug
# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
#config.action_controller.session_store = :active_record_store
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
# Make Active Record use UTC-base instead of local time
config.active_record.default_timezone = :utc
config.i18n.default_locale = "en"
# Use Active Record's schema dumper instead of SQL when creating the test database
# (enables use of different database adapters for development and test environments)
# config.active_record.schema_format = :ruby
# See Rails::Configuration for more options
config.action_controller.session = { :session_key => "_mailr_session", :secret => "123456789012345678901234567890" }
end
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# Include your application configuration below
default_config_path = 'config/default_site'
default_config = File.join(RAILS_ROOT, default_config_path)
require default_config
begin
require File.join(RAILS_ROOT, 'config/site')
CDF::CONFIG.update(CDF::LOCALCONFIG) if CDF::LOCALCONFIG
rescue LoadError
STDERR.puts 'WARNING: config/site.rb not found, using default settings from ' + default_config_path
end
#if CONFIG[:locale] is nil then I18n.default_locale will be used
I18n.default_locale = CDF::CONFIG[:locale]
require 'tmail_patch'
$KCODE = 'u'
require 'jcode'
# set UTF8 as a client interface to Database
RAILS_DEFAULT_LOGGER.debug("Using MySQL Version #{CDF::CONFIG[:mysql_version]}")
ActiveRecord::Base.connection.execute("SET NAMES utf8", 'Set Client encoding to UTF8') if CDF::CONFIG[:mysql_version] == '4.1'
ActiveRecord::Base.connection.execute("set character set utf8", 'Set Connection encoding to UTF8') if CDF::CONFIG[:mysql_version] == '4.1'
require 'imapmailbox'
[IMAPMailbox, IMAPFolderList, IMAPFolder].each { |mod| mod.logger ||= RAILS_DEFAULT_LOGGER }
# Initialize the rails application
Rails3::Application.initialize!

34
config/environments/development.rb Normal file → Executable file
View file

@ -1,14 +1,26 @@
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
Rails3::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

56
config/environments/production.rb Normal file → Executable file
View file

@ -1,17 +1,49 @@
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
Rails3::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# For nginx:
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
# Disable delivery errors if you bad email addresses should just be ignored
# config.action_mailer.raise_delivery_errors = false
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
# See everything in the log (default is :info)
# config.log_level = :debug
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_assets = false
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end

50
config/environments/test.rb Normal file → Executable file
View file

@ -1,23 +1,35 @@
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
Rails3::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Tell ActionMailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Overwrite the default settings for fixtures in tests. See Fixtures
# for more details about these settings.
# config.transactional_fixtures = true
# config.instantiated_fixtures = false
# config.pre_loaded_fixtures = false
# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end

View file

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View file

@ -0,0 +1,10 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end

View file

@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View file

@ -0,0 +1,36 @@
# config/initializers/pluralization.rb
module I18n::Backend::Pluralization
# rules taken from : http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
def pluralize(locale, entry, n)
return entry unless entry.is_a?(Hash) && n
if n == 0 && entry.has_key?(:zero)
key = :zero
else
key = case locale
when :pl # Polish
n==1 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other
when :cs, :sk # Czech, Slovak
n==1 ? :one : (n>=2 && n<=4) ? :few : :other
when lt # Lithuanian
n%10==1 && n%100!=11 ? :one : n%10>=2 && (n%100<10 || n%100>=20) ? :few : :other
when :lv # Latvian
n%10==1 && n%100!=11 ? :one : n != 0 ? :few : :other
when :ru, :uk, :sr, :hr # Russian, Ukrainian, Serbian, Croatian
n%10==1 && n%100!=11 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other
when :sl # Slovenian
n%100==1 ? :one : n%100==2 ? :few : n%100==3 || n%100==4 ? :many : :other
when :ro # Romanian
n==1 ? :one : (n==0 || (n%100 > 0 && n%100 < 20)) ? :few : :other
when :gd # Gaeilge
n==1 ? :one : n==2 ? :two : :other;
# add another language if you like...
else
n==1 ? :one : :other # default :en
end
end
raise InvalidPluralizationData.new(entry, n) unless entry.has_key?(key)
entry[key]
end
end
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

View file

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Rails3::Application.config.secret_token = 'ade84d567b0c637fd3547fd18b97d1677fd6ca3c5331e6ed1a1b13bb6a7823cc367cbe317caf102f29f8c35eb487ff3ca33e6321d037c14ebb055eb530841ff6'

View file

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
Rails3::Application.config.session_store :cookie_store, :key => '_rails3_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Rails3::Application.config.session_store :active_record_store

View file

@ -1,79 +0,0 @@
server.port = 80
server.bind = "127.0.0.1"
#server.event-handler = "freebsd-kqueue"
server.modules = ( "mod_rewrite", "mod_fastcgi", )
server.indexfiles = ( "dispatch.fcgi" )
server.document-root = "public/"
server.error-handler-404 = "/dispatch.fcgi"
server.errorlog = "log/error.log"
url.rewrite = ( "^/$" => "/login", "^([^.]+)$" => "$1.html" )
#### fastcgi module
fastcgi.server = (
".fcgi" => (
"mailr" => (
"min-procs" => 2,
"max-procs" => 2,
"socket" => "/tmp/mailr1.socket",
"bin-path" => "public/dispatch.fcgi",
"idle-timeout" => 120,
"bin-environment" => ( "RAILS_ENV" => "production" )
)
)
)
mimetype.assign = (
".rpm" => "application/x-rpm",
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "audio/x-wav",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)

7
config/locales/en.yml Normal file → Executable file
View file

@ -1,7 +1,7 @@
en:
mailr: Mailr
email: Email
password: Password
password: Password
log_in: Log In
wrong_email_or_password: Wrong email or password specified.
mailbox: Mailbox
@ -46,7 +46,7 @@ en:
cc: CC
bcc: BCC
send: Send
choose_address: Choose addresses from contacts
choose_address: Choose addresses from contacts
compose_txt: Compose new mail
attachment: Attachment
add: Add
@ -59,8 +59,9 @@ en:
save: Save
cancel: Cancel
add_one_contact: Add one contact
add_multiple: Add multiple
add_multiple: Add multiple
name: name
add_folder: Add folder
total_messages: Total messages
unseen: Unseen
please_login: Log in

0
config/locales/es-ES.yml Normal file → Executable file
View file

6
config/locales/pl-PL.yml → config/locales/pl.yml Normal file → Executable file
View file

@ -1,4 +1,4 @@
pl-PL:
pl:
mailr: Mailr
email: E-mail
password: Hasło
@ -7,7 +7,7 @@ pl-PL:
mailbox: Poczta
folders: Foldery
folder: Folder
empty: Pusty
empty: Opróżnij
logout: Wyloguj
compose: Nowa wiadomość
preferences: Ustawienia
@ -68,3 +68,5 @@ pl-PL:
user_logged_out: Użytkownik został wylogowany
please_login: Logowanie
add_to_contacts: Dodaj do kontaktów
want_to_empty_trash_message: Czy chcesz opróznic kosz?

99
config/routes.rb Normal file → Executable file
View file

@ -1,27 +1,78 @@
ActionController::Routing::Routes.draw do |map|
map.resources :folders, :requirements => {:id => /[^\/]+/}
map.resources :contacts, :member => {:add_from_mail => :get}, :collection => {:add_multiple => :get}
map.resources :contact_groups
Rails3::Application.routes.draw do
resources :folders
resources :contacts do
collection do
get :add_multiple
end
member do
get :add_from_mail
end
end
# Add your own custom routes here.
# The priority is based upon order of creation: first created -> highest priority.
# Here's a sample route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
map.root :controller=>'webmail', :action=>'index'
resources :contact_groups
match '/' => 'webmail#index'
match 'webmail' => 'webmail#index'
match 'webmail/:action' => 'webmail#index'
match '/contact/:action' => 'contacts#index'
match 'admin/main' => 'login#logout'
match ':controller/service.wsdl' => '#wsdl'
match '/:controller(/:action(/:id))'
map.connect 'webmail', :controller=>'webmail', :action=>'index'
map.connect 'webmail/:action', :controller=>'webmail'
map.connect '/contact/:action', :controller=>'contacts'
map.connect 'admin/main', :controller=> 'login', :action=>'logout'
# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
# Install the default route as the lowest priority.
map.connect ':controller/:action/:id'
end
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => "welcome#index"
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'

0
db/migrate/20090107193228_init.rb Normal file → Executable file
View file

View file

@ -1,111 +0,0 @@
CREATE TABLE customers (
id bigint(20) NOT NULL auto_increment,
fname varchar(50) default NULL,
lname varchar(50) default NULL,
email varchar(100) NOT NULL,
PRIMARY KEY (id),
UNIQUE INDEX (email)
) TYPE=MyISAM;
CREATE TABLE filters (
id bigint(20) NOT NULL auto_increment,
name varchar(50) default NULL,
destination_folder varchar(50) default NULL,
customer_id bigint(20) NOT NULL,
order_num int default 1,
PRIMARY KEY (id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customers(id)
) TYPE=MyISAM;
CREATE TABLE expressions (
id bigint(20) NOT NULL auto_increment,
field_name varchar(20) default '^Subject' NOT NULL,
operator varchar(20) default 'contains' NOT NULL,
expr_value varchar(100) default '' NOT NULL,
case_sensitive bool default 0,
filter_id bigint(20) NOT NULL,
PRIMARY KEY (id),
INDEX (filter_id),
FOREIGN KEY (filter_id) REFERENCES filters(id)
) TYPE=MyISAM;
CREATE TABLE `mail_prefs` (
`id` int(11) NOT NULL auto_increment,
`mail_type` varchar(10) default 'text/plain',
`wm_rows` int(11) default '20',
`customer_id` bigint(20) default NULL,
`check_external_mail` tinyint(1) default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `customer_id` (`customer_id`)
) TYPE=MyISAM;
CREATE TABLE contacts (
id bigint(20) NOT NULL auto_increment,
fname varchar(50) default NULL,
lname varchar(50) default NULL,
email varchar(100) default NULL,
hphone varchar(20) default NULL,
wphone varchar(20) default NULL,
mobile varchar(20) default NULL,
fax varchar(20) default NULL,
notes text,
create_date datetime default NULL,
delete_date datetime default NULL,
customer_id bigint(20) default NULL,
PRIMARY KEY (id),
INDEX (customer_id),
INDEX (customer_id, email),
INDEX (email),
FOREIGN KEY (customer_id) REFERENCES customers(id)
) TYPE=MyISAM;
CREATE TABLE contact_groups (
id bigint(20) NOT NULL auto_increment,
name varchar(50) default NULL,
customer_id bigint(20) default NULL,
PRIMARY KEY (id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customers(id)
) TYPE=MyISAM;
CREATE TABLE contact_contact_groups (
contact_id bigint(20) NOT NULL,
contact_group_id bigint(20) NOT NULL,
PRIMARY KEY (contact_id, contact_group_id),
INDEX (contact_id),
INDEX (contact_group_id),
FOREIGN KEY (contact_id) REFERENCES contacts(id),
FOREIGN KEY (contact_group_id) REFERENCES contact_groups(id)
) TYPE=MyISAM;
-- Mysql Sessions
create table sessions (
id bigint(20) NOT NULL auto_increment,
session_id varchar(255),
data text,
updated_at timestamp,
primary key(id),
index(session_id)
);
-- Cache
CREATE TABLE imap_messages (
id bigint(20) NOT NULL auto_increment,
folder_name varchar(100) NOT NULL,
username varchar(100) NOT NULL,
msg_id varchar(100),
uid bigint(20) NOT NULL,
`from` varchar(255),
`from_flat` varchar(255),
`to` varchar(255),
`to_flat` varchar(255),
`subject` varchar(255),
`content_type` varchar(30),
`date` timestamp,
`unread` tinyint(1),
`size` bigint(20),
PRIMARY KEY (id),
INDEX (folder_name, username),
INDEX (folder_name, username,uid)
) TYPE=MyISAM;

View file

@ -1,111 +0,0 @@
CREATE TABLE customers (
id bigserial NOT NULL,
fname varchar(50) default NULL,
lname varchar(50) default NULL,
email varchar(100) NOT NULL,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX customers_email_idx ON customers(email);
CREATE TABLE filters (
id bigserial NOT NULL,
name varchar(50) default NULL,
destination_folder varchar(50) default NULL,
customer_id bigint NOT NULL,
order_num int default 1,
PRIMARY KEY (id),
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
CREATE INDEX filters_customer_id_idx ON filters(customer_id);
CREATE TABLE expressions (
id bigserial NOT NULL,
field_name varchar(20) default '^Subject' NOT NULL,
operator varchar(20) default 'contains' NOT NULL,
expr_value varchar(100) default '' NOT NULL,
case_sensitive bool default FALSE,
filter_id bigint NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (filter_id) REFERENCES filters(id)
);
CREATE INDEX expressions_filter_id_idx ON expressions(filter_id);
CREATE TABLE mail_prefs (
id serial NOT NULL,
mail_type varchar(10) default 'text/plain',
wm_rows int default '20',
customer_id bigint default NULL,
check_external_mail bool default false,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX mail_prefs_customer_id_idx ON mail_prefs(customer_id);
CREATE TABLE contacts (
id bigserial NOT NULL,
fname varchar(50) default NULL,
lname varchar(50) default NULL,
email varchar(100) default NULL,
hphone varchar(20) default NULL,
wphone varchar(20) default NULL,
mobile varchar(20) default NULL,
fax varchar(20) default NULL,
notes text,
create_date timestamp default NULL,
delete_date timestamp default NULL,
customer_id bigint default NULL,
PRIMARY KEY (id),
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
CREATE INDEX contacts_customer_id_idx ON contacts(customer_id);
CREATE INDEX contacts_customer_id_email_idx ON contacts(customer_id,email);
CREATE INDEX contacts_email_idx ON contacts(email);
CREATE TABLE contact_groups (
id bigserial NOT NULL,
name varchar(50) default NULL,
customer_id bigint default NULL,
PRIMARY KEY (id),
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
CREATE INDEX contact_groups_customer_id_idx ON contact_groups(customer_id);
CREATE TABLE contact_contact_groups (
contact_id bigint NOT NULL,
contact_group_id bigint NOT NULL,
PRIMARY KEY (contact_id, contact_group_id),
FOREIGN KEY (contact_id) REFERENCES contacts(id),
FOREIGN KEY (contact_group_id) REFERENCES contact_groups(id)
);
CREATE INDEX contact_contact_groups_contact_id_idx ON contact_contact_groups(contact_id);
CREATE INDEX contact_contact_groups_contact_group_id_idx ON contact_contact_groups(contact_group_id);
create table sessions (
id BIGSERIAL NOT NULL,
session_id VARCHAR(255) NULL,
data TEXT NULL,
updated_at TIMESTAMP default null,
PRIMARY KEY (id)
);
CREATE INDEX session_idx ON sessions(session_id);
CREATE TABLE imap_messages (
id BIGSERIAL NOT NULL,
folder_name VARCHAR(100) NOT NULL,
username VARCHAR(100) NOT NULL,
msg_id VARCHAR(100),
uid BIGINT NOT NULL,
"from" TEXT,
"from_flat" TEXT,
"to" TEXT,
"to_flat" TEXT,
"subject" TEXT,
"content_type" VARCHAR(30),
"date" TIMESTAMP,
"unread" BOOL default false,
"size" BIGINT,
PRIMARY KEY (id)
);
CREATE INDEX msg_cache_fu_idx ON imap_messages(folder_name, username);
CREATE INDEX msg_cache_fuui_idx ON imap_messages(folder_name, username, uid);

13
db/schema.rb Normal file → Executable file
View file

@ -1,10 +1,11 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
# to create the application database on another system, you should be using db:schema:load, not running
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

7
db/seeds.rb Executable file
View file

@ -0,0 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)

2
doc/README_FOR_APP Normal file → Executable file
View file

@ -1,2 +1,2 @@
Use this README file to introduce your application and point to useful places in the API for learning more.
Run "rake appdoc" to generate API documentation for your models and controllers.
Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.

0
lib/cdfutils.rb Normal file → Executable file
View file

14
lib/imap_utils.rb Normal file → Executable file
View file

@ -1,5 +1,5 @@
module ImapUtils
private
private
def load_imap_session
return if ['error_connection'].include?(action_name)
@ -8,7 +8,7 @@ module ImapUtils
def get_imap_session
begin
@mailbox = IMAPMailbox.new
@mailbox = IMAPMailbox.new(self.logger)
uname = (get_mail_prefs.check_external_mail == 1 ? user.email : user.local_email)
upass = get_upass
@mailbox.connect(uname, upass)
@ -17,7 +17,7 @@ module ImapUtils
# logger.error("Exception on loggin webmail session - #{ex} - #{ex.backtrace.join("\t\n")}")
# render :action => "error_connection"
render :text => ex.inspect, :content_type => 'text/plain'
end
end
end
def close_imap_session
@ -31,7 +31,7 @@ module ImapUtils
if not(@mailprefs = MailPref.find_by_customer_id(logged_customer))
@mailprefs = MailPref.create("customer_id"=>logged_customer)
end
end
end
@mailprefs
end
@ -41,8 +41,8 @@ module ImapUtils
else
# retrun it plain
session["wmp"]
end
end
end
end
def load_folders
if have_to_load_folders?()
@ -53,7 +53,7 @@ module ImapUtils
end
session["folder_name"] = @folder_name
@folders = @mailbox.folders if @folders.nil?
end
end
end
def user

0
lib/tasks/.gitkeep Executable file
View file

0
lib/tmail_patch.rb Normal file → Executable file
View file

0
lib/webmail/bounced_mail.rb Normal file → Executable file
View file

134
lib/webmail/cdfmail.rb Normal file → Executable file
View file

@ -6,35 +6,35 @@ module CDF
end
class CDF::Mail
include ActionMailer::Quoting
#include ActionMailer::Quoting #upgrade to Rails3
def initialize(senderTempLocation)
@attachments = Array.new
@sender_temp_location = senderTempLocation
@to_contacts = Array.new
end
def customer_id() @customer_id end
def customer_id=(arg) @customer_id = arg end
def from() @from end
def from=(arg) @from = arg end
def to() @to end
def to=(arg) @to = arg end
def to_contacts() @to_contacts end
def to_contacts=(arg) @to_contacts = arg end
def toc=(arg)
@to_contacts = Array.new
arg.split(",").each { |token| @to_contacts << token.to_i unless token == "" or token.strip() == "undefined"} unless arg.nil? or arg == "undefined"
end
def toc
ret = String.new
@to_contacts.each { |contact|
@ -47,60 +47,60 @@ class CDF::Mail
}
ret
end
def bcc() @bcc end
def bcc=(arg) @bcc = arg end
def cc() @cc end
def cc=(arg) @cc = arg end
def subject() @subject end
def subject=(arg) @subject = arg end
def attachments
@attachments
end
def add_attachment(attachment)
@attachments << attachment
end
def multipart?
@attachments && @attachments.size > 0
end
def delete_attachment(att_filename)
@attachments.each { |att| att.delete_temp_data() if arr.filename == att_filename }
@attachments.delete_if() { |att| att.filename == att_filename }
end
def delete_attachments()
@attachments.each { |att| att.delete_temp_data() }
@attachments = Array.new
end
def body() @body end
def body=(arg) @body = arg end
def content_type() @content_type end
def content_type=(arg) @content_type = arg end
def temp_location() @sender_temp_location end
def send_mail(db_msg_id = 0)
m = TMail::Mail.new
m.from, m.body = self.from, self.body
m.date = Time.now
m.subject, = quote_any_if_necessary("UTF-8", self.subject)
m.subject, = quote_any_if_necessary("UTF-8", self.subject)
m.to = decode_addresses(self.to)
m.cc, m.bcc = decode_addresses(self.cc), decode_addresses(self.bcc)
if multipart?
m.set_content_type("multipart/mixed")
p = TMail::Mail.new(TMail::StringPort.new(""))
@ -127,21 +127,21 @@ class CDF::Mail
}
encmail = m.encoded
RAILS_DEFAULT_LOGGER.debug("Sending message \n #{encmail}")
Net::SMTP.start(ActionMailer::Base.smtp_settings[:address], ActionMailer::Base.smtp_settings[:port],
ActionMailer::Base.smtp_settings[:domain], ActionMailer::Base.smtp_settings[:user_name],
Net::SMTP.start(ActionMailer::Base.smtp_settings[:address], ActionMailer::Base.smtp_settings[:port],
ActionMailer::Base.smtp_settings[:domain], ActionMailer::Base.smtp_settings[:user_name],
ActionMailer::Base.smtp_settings[:password], ActionMailer::Base.smtp_settings[:authentication]) do |smtp|
smtp.sendmail(encmail, m.from, m.destinations)
end
return encmail
end
def forward(tmail, fb)
decoded_subject = mime_encoded?(tmail.subject) ? mime_decode(tmail.subject) : tmail.subject
self.subject = "[Fwd: #{decoded_subject}]"
attachment = CDF::Attachment.new(self)
attachment.body(tmail, fb)
end
def reply(tmail, fb, type)
decoded_subject = mime_encoded?(tmail.subject) ? mime_decode(tmail.subject) : tmail.subject
self.subject = "Re: #{decoded_subject}"
@ -152,9 +152,9 @@ class CDF::Mail
mt = MailTransform.new
self.body = mt.get_body(tmail, type)
end
private
private
def delimeter
if self.content_type == "text/plain"
"\n"
@ -162,41 +162,41 @@ class CDF::Mail
"<br/>"
end
end
def text2html(str) CGI.escapeHTML(str).gsub("\n", "<br/>") end
def html2text(txt)
clear_html(txt)
end
def prepare_text(msg, ctype, bdy)
msg.set_content_type(ctype, nil, {"charset"=>"utf-8"})
msg.transfer_encoding = "8bit"
msg.body = bdy
end
def prepare_html(msg, ctype, bdy)
msg.set_content_type(ctype, nil, {"charset"=>"utf8"})
msg.transfer_encoding = "8bit"
msg.body = bdy
end
def prepare_alternative(msg, bdy)
bound = ::TMail.new_boundary
msg.set_content_type("multipart/alternative", nil, {"charset"=>"utf8", "boundary"=>bound})
msg.transfer_encoding = "8bit"
ptext = TMail::Mail.new(TMail::StringPort.new(""))
phtml = TMail::Mail.new(TMail::StringPort.new(""))
prepare_text(ptext, "text/plain", html2text(bdy))
prepare_html(phtml, "text/html", bdy)
msg.parts << ptext
msg.parts << phtml
end
def decode_addresses(str)
ret = String.new
str.split(",").each { |addr|
@ -218,37 +218,37 @@ class CDF::Mail
ret
end
end
class CDF::Attachment
def initialize(arg)
@mail = arg
@mail.add_attachment(self)
@index = @mail.attachments.size - 1
end
def filename=(arg)
@filename = arg.tr('\\/:*?"\'<>|', '__________')
end
def filename() @filename end
def temp_filename=(arg) @temp_filename = arg end
def temp_filename() @temp_filename end
def content_type=(arg) @content_type = arg end
def content_type() @content_type end
def delete_temp_data()
File.delete(self.temp_filename)
end
def file
File.open(self.temp_filename, "rb") { |fp| fp.read }
end
def file=(data)
return if data.size == 0
@content_type = data.content_type
@ -258,7 +258,7 @@ class CDF::Attachment
data.rewind
File.open(@temp_filename, "wb") { |f| f.write(data.read) }
end
def body(data, fb)
@content_type = "message/rfc822"
filename = data.content_type['filename']
@ -267,7 +267,7 @@ class CDF::Attachment
check_store_path
File.open(@temp_filename, "wb") { |f| f.write(fb) }
end
def check_store_path()
path = ""
"#{@mail.temp_location}".split(File::SEPARATOR).each { |p|
@ -275,11 +275,11 @@ class CDF::Attachment
begin
Dir.mkdir(path)
rescue
end
end
path << File::SEPARATOR
}
}
end
def encoded
p = TMail::Mail.new(TMail::StringPort.new(""))
data = self.file
@ -294,13 +294,13 @@ class CDF::Attachment
p.set_content_type(@content_type, nil, {"charset"=>"utf8"})
p.set_disposition("inline;")
p.transfer_encoding = "8bit"
else
else
p.set_content_type(@content_type, nil, {"name"=>@filename})
p.set_disposition("inline; filename=#{@filename}") unless @filename.nil?
p.set_disposition("inline;") if @filename.nil?
p.transfer_encoding='Base64'
p.body = TMail::Base64.folding_encode(data)
end
return p
return p
end
end

0
lib/webmail/environment.rb Normal file → Executable file
View file

0
lib/webmail/expression.rb Normal file → Executable file
View file

0
lib/webmail/filter.rb Normal file → Executable file
View file

0
lib/webmail/imap_message.rb Normal file → Executable file
View file

189
lib/webmail/imapmailbox.rb Normal file → Executable file
View file

@ -22,9 +22,9 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# Modifications (c) 2005 by littlegreen
#
#
require 'net/imap'
Net::IMAP.debug = true if CDF::CONFIG[:debug_imap]
@ -34,8 +34,8 @@ class Net::IMAP
def process(data)
return "\0#{@user}\0#{@password}"
end
private
private
def initialize(user, password)
@user = user
@password = password
@ -61,17 +61,20 @@ class IMAPMailbox
attr_reader :connected
attr_accessor :selected_mailbox
cattr_accessor :logger
def initialize
def initialize(logger)
@selected_mailbox = ''
@folders = {}
@connected = false
@logger = logger
end
def connect(username, password)
#logger.debug "*** connect: @connected"
unless @connected
use_ssl = CDF::CONFIG[:imap_use_ssl] ? true : false
port = CDF::CONFIG[:imap_port] || (use_ssl ? 993 : 143)
# logger.debug "*** IMAP params: use_ssl => #{use_ssl}, port => #{port}"
begin
@imap = Net::IMAP.new(CDF::CONFIG[:imap_server], port, use_ssl)
rescue Net::IMAP::ByeResponseError => bye
@ -80,26 +83,26 @@ class IMAPMailbox
System.sleep(CDF::CONFIG[:imap_bye_timeout_retry_seconds])
@imap = Net::IMAP.new(CDF::CONFIG[:imap_server], port, use_ssl)
rescue Error => ex
logger.error "Error on authentication!"
logger.error bye.backtrace.join("\n")
# logger.error "Error on authentication!"
# logger.error bye.backtrace.join("\n")
raise AuthenticationError.new
end
end
rescue Net::IMAP::NoResponseError => noresp
logger.error "Error on authentication!"
logger.error noresp.backtrace.join("\n")
# logger.error "Error on authentication!"
# logger.error noresp.backtrace.join("\n")
raise AuthenticationError.new
rescue Net::IMAP::BadResponseError => bad
logger.error "Error on authentication!"
logger.error bad.backtrace.join("\n")
# logger.error "Error on authentication!"
# logger.error bad.backtrace.join("\n")
raise AuthenticationError.new
rescue Net::IMAP::ResponseError => resp
logger.error "Error on authentication!"
logger.error resp.backtrace.join("\n")
# logger.error "Error on authentication!"
# logger.error resp.backtrace.join("\n")
raise AuthenticationError.new
end
end
@username = username
begin
logger.error "IMAP authentication - #{CDF::CONFIG[:imap_auth]}."
# logger.error "IMAP authentication - #{CDF::CONFIG[:imap_auth]}."
if CDF::CONFIG[:imap_auth] == 'NOAUTH'
@imap.login(username, password)
else
@ -107,17 +110,17 @@ class IMAPMailbox
end
@connected = true
rescue Exception => ex
logger.error "Error on authentication!"
logger.error ex.backtrace.join("\n")
# logger.error "Error on authentication!"
# logger.error ex.backtrace.join("\n")
raise AuthenticationError.new
end
end
end
def imap
@imap
end
# Function chnage password works only if root has run imap_backend
# and users courier-authlib utility authtest - from courier-imap version 4.0.1
def change_password(username, password, new_password)
@ -127,34 +130,34 @@ class IMAPMailbox
if ret.include?("Password change succeeded.")
return true
else
logger.error "[!] Error on change password! - #{ret}"
logger.error "[!] Error on change password! - #{ret}"
return false
end
end
end
def disconnect
if @connected
@imap.logout
#@imap.disconnect
@imap = nil
@connected = false
end
end
end
def [](mailboxname)
@last_folder = IMAPFolderList.new(self, @username)[mailboxname]
end
def folders
# reference just to stop GC
@folder_list ||= IMAPFolderList.new(self, @username)
@folder_list
end
def reload
@folder_list.reload if @folder_list
end
def create_folder(name)
# begin
@imap.create(Net::IMAP.encode_utf7(name))
@ -162,16 +165,16 @@ class IMAPMailbox
# rescue Exception=>e
# end
end
def delete_folder(name)
begin
@imap.delete(folders[name].utf7_name)
reload
rescue Exception=>e
logger.error("Exception on delete #{name} folder #{e}")
logger.error("Exception on delete #{name} folder #{e}")
end
end
def message_sent(message)
# ensure we have sent folder
begin
@ -179,14 +182,14 @@ class IMAPMailbox
rescue Exception=>e
end
begin
@imap.append(CDF::CONFIG[:mail_sent], message)
@imap.append(CDF::CONFIG[:mail_sent], message)
folders[CDF::CONFIG[:mail_sent]].cached = false if folders[CDF::CONFIG[:mail_sent]]
rescue Exception=>e
logger.error("Error on append - #{e}")
logger.error("Error on append - #{e}")
end
end
def message_bulk(message)
# ensure we have sent folder
begin
@ -194,24 +197,24 @@ class IMAPMailbox
rescue Exception=>e
end
begin
@imap.append(CDF::CONFIG[:mail_bulk_sent], message)
@imap.append(CDF::CONFIG[:mail_bulk_sent], message)
folders[CDF::CONFIG[:mail_sent]].cached = false if folders[CDF::CONFIG[:mail_bulk_sent]]
rescue Exception=>e
logger.error("Error on bulk - #{e}")
end
logger.error("Error on bulk - #{e}")
end
end
end
class IMAPFolderList
include Enumerable
cattr_accessor :logger
def initialize(mailbox, username)
@mailbox = mailbox
@folders = Hash.new
@username = username
end
def each
refresh if @folders.empty?
#@folders.each_value { |folder| yield folder }
@ -219,11 +222,11 @@ class IMAPFolderList
@folders.sort.each { |pair| yield pair.last }
end
def reload
refresh
end
def [](name)
refresh if @folders.empty?
@folders[name]
@ -233,7 +236,7 @@ class IMAPFolderList
def refresh
@folders = {}
result = @mailbox.imap.list('', '*')
if result
if result
result.each do |info|
folder = IMAPFolder.new(@mailbox, info.name, @username, info.attr, info.delim)
@folders[folder.name] = folder
@ -257,14 +260,14 @@ class IMAPFolder
attr_reader :username
attr_reader :delim
attr_reader :attribs
attr_writer :cached
attr_writer :mcached
cattr_accessor :logger
@@fetch_attr = ['ENVELOPE','BODYSTRUCTURE', 'FLAGS', 'UID', 'RFC822.SIZE']
def initialize(mailbox, utf7_name, username, attribs, delim)
@mailbox = mailbox
@utf7_name = utf7_name
@ -276,7 +279,7 @@ class IMAPFolder
@cached = false
@mcached = false
end
def activate
if(@mailbox.selected_mailbox != @name)
@mailbox.selected_mailbox = @name
@ -284,7 +287,7 @@ class IMAPFolder
load_total_unseen if !@cached
end
end
# Just delete message without interaction with Trash folder
def delete(message)
activate
@ -295,17 +298,17 @@ class IMAPFolder
ImapMessage.delete_all(["username = ? and folder_name = ? and uid = ?", @username, @name, uid])
@cached = false
end
# Deleted messages - move to trash folder
def delete_multiple(uids)
# ensure we have trash folder
begin
@mailbox.imap.create(CDF::CONFIG[:mail_trash])
rescue
rescue
end
move_multiple(uids, CDF::CONFIG[:mail_trash])
end
def copy(message, dst_folder)
uid = (message.kind_of?(Integer) ? message : message.uid)
activate
@ -313,14 +316,14 @@ class IMAPFolder
@mailbox.folders[dst_folder].cached = false if @mailbox.folders[dst_folder]
@mailbox.folders[dst_folder].mcached = false if @mailbox.folders[dst_folder]
end
def copy_multiple(message_uids, dst_folder)
activate
@mailbox.imap.uid_copy(message_uids, dst_folder)
@mailbox.folders[dst_folder].cached = false if @mailbox.folders[dst_folder]
@mailbox.folders[dst_folder].mcached = false if @mailbox.folders[dst_folder]
end
def move(message, dst_folder)
uid = (message.kind_of?(Integer) ? message : message.uid)
activate
@ -333,7 +336,7 @@ class IMAPFolder
@cached = false
@mcached = false
end
def move_multiple(message_uids, dst_folder)
activate
@mailbox.imap.uid_copy(message_uids, @mailbox.folders[dst_folder].utf7_name)
@ -345,7 +348,7 @@ class IMAPFolder
@cached = false
@mcached = false
end
def mark_read(message_uid)
activate
cached = ImapMessage.find(:first, :conditions => ["username = ? and folder_name = ? and uid = ?", @username, @name, message_uid])
@ -357,7 +360,7 @@ class IMAPFolder
@unseen_messages = @unseen_messages - 1
end
end
def mark_unread(message_uid)
activate
cached = ImapMessage.find(:first, :conditions => ["username = ? and folder_name = ? and uid = ?", @username, @name, message_uid])
@ -369,7 +372,7 @@ class IMAPFolder
@unseen_messages = @unseen_messages + 1
end
end
def expunge
activate
@mailbox.imap.expunge
@ -385,33 +388,33 @@ class IMAPFolder
count = @mailbox.imap.fetch(1..-1, "UID")
to = count.size if count.size < to
range = (offset..to)
logger.info range.inspect
#logger.info range.inspect
server_messages = @mailbox.imap.fetch(range, "(UID FLAGS)")
#server_messages = @mailbox.imap.uid_fetch(sequence_uids, ["UID", "FLAGS"])
startDbFetch = Time.now
cached_messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name])
cached_unread_uids = Array.new
cached_read_uids = Array.new
uids_to_be_deleted = Array.new
cached_messages.each { |msg|
cached_messages.each { |msg|
cached_unread_uids << msg.uid if msg.unread
cached_read_uids << msg.uid unless msg.unread
uids_to_be_deleted << msg.uid
}
uids_to_be_fetched = Array.new
server_msg_uids = Array.new
uids_unread = Array.new
uids_read = Array.new
server_messages.each { |server_msg|
server_messages.each { |server_msg|
uid, flags = server_msg.attr['UID'], server_msg.attr['FLAGS']
server_msg_uids << uid
unless uids_to_be_deleted.include?(uid)
@ -421,32 +424,32 @@ class IMAPFolder
uids_read << uid
elsif !flags.member?(:Seen) && cached_read_uids.include?(uid)
uids_unread << uid
end
end
end
uids_to_be_deleted.delete(uid)
} unless server_messages.nil?
ImapMessage.delete_all(["username = ? and folder_name = ? and uid in ( ? )", @username, @name, uids_to_be_deleted]) unless uids_to_be_deleted.empty?
ImapMessage.update_all('unread = 0', ["username = ? and folder_name = ? and uid in ( ? )", @username, @name, uids_read]) unless uids_read.empty?
ImapMessage.update_all('unread = 1', ["username = ? and folder_name = ? and uid in ( ? )", @username, @name, uids_unread]) unless uids_unread.empty?
# fetch and store not cached messages
unless uids_to_be_fetched.empty?
logger.debug("About to fetch #{uids_to_be_fetched.join(",")}")
unless uids_to_be_fetched.empty?
# logger.debug("About to fetch #{uids_to_be_fetched.join(",")}")
uids_to_be_fetched.each_slice(20) do |slice|
fetch_uids(slice)
end
end
end
#FIX: @mcached = true
logger.debug("Synchonization done for folder #{@name} in #{Time.now - startSync} ms.")
# logger.debug("Synchonization done for folder #{@name} in #{Time.now - startSync} ms.")
end
def fetch_uids(uids)
imapres = @mailbox.imap.uid_fetch(uids, @@fetch_attr)
imapres.each { |cache|
imapres.each { |cache|
envelope = cache.attr['ENVELOPE'];
message = ImapMessage.create( :folder_name => @name,
message = ImapMessage.create( :folder_name => @name,
:username => @username,
:msg_id => envelope.message_id,
:uid => cache.attr['UID'],
@ -459,18 +462,18 @@ class IMAPFolder
:size => cache.attr['RFC822.SIZE'])
}
end
def messages(offset = 0, limit = 10, sort = 'date desc')
# Synchronize first retrieval time
synchronize_cache(offset+1, limit) #unless @mcached
if limit == -1
@messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name], :order => sort)
else
@messages = ImapMessage.find(:all, :conditions => ["username = ? and folder_name = ?", @username, @name], :order => sort )
end
end
end
def messages_search(query = ["ALL"], sort = 'date desc')
activate
uids = @mailbox.imap.uid_search(query)
@ -481,38 +484,38 @@ class IMAPFolder
else
return Array.new
end
end
def message(uid)
activate
message = ImapMessage.find(:first, :conditions => ["username = ? and folder_name = ? and uid = ?", @username, @name, uid])
message.set_folder(self)
message
end
def unseen
activate
load_total_unseen if !@cached
@unseen_messages
@unseen_messages
end
def total
activate
load_total_unseen if !@cached
@total_messages
end
def load_total_unseen
stat = @mailbox.imap.status(@utf7_name, ["MESSAGES", "UNSEEN"])
@total_messages, @unseen_messages = stat["MESSAGES"], stat['UNSEEN']
@cached = true
end
def update_status
@status ||= @mailbox.imap.status(@utf7_name, ["MESSAGES"])
end
def subscribe
@mailbox.imap.subscribe(@utf7_name)
end

0
lib/webmail/mail2screen.rb Normal file → Executable file
View file

0
lib/webmail/mail_transform.rb Normal file → Executable file
View file

0
lib/webmail/maildropserializator.rb Normal file → Executable file
View file

0
lib/webmail/routes.rb Normal file → Executable file
View file

0
lib/webmail/virtual_email.rb Normal file → Executable file
View file

28
public/404.html Normal file → Executable file
View file

@ -1,8 +1,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<h1>File not found</h1>
<p>Change this error message for pages not found in public/404.html</p>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>
</html>

26
public/422.html Executable file
View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show more