gfdnavi 1.3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +10949 -0
- data/LICENCE.txt +57 -0
- data/Makefile +18 -0
- data/TODO +132 -0
- data/app/controllers/analysis_controller.rb +700 -0
- data/app/controllers/application.rb +41 -0
- data/app/controllers/draw_method_controller.rb +172 -0
- data/app/controllers/explorer_controller.rb +197 -0
- data/app/controllers/finder_controller.rb +331 -0
- data/app/controllers/function_controller.rb +204 -0
- data/app/controllers/group_controller.rb +115 -0
- data/app/controllers/keyword_attributes_controller.rb +52 -0
- data/app/controllers/knowledge_controller.rb +928 -0
- data/app/controllers/nodes_controller.rb +515 -0
- data/app/controllers/search_controller.rb +341 -0
- data/app/controllers/user_controller.rb +337 -0
- data/app/helpers/analysis_helper.rb +2 -0
- data/app/helpers/application_helper.rb +105 -0
- data/app/helpers/description_helper.rb +2 -0
- data/app/helpers/function_helper.rb +2 -0
- data/app/helpers/group_helper.rb +2 -0
- data/app/helpers/search_helper.rb +3 -0
- data/app/helpers/user_helper.rb +2 -0
- data/app/helpers/work_flow_helper.rb +92 -0
- data/app/models/actual_file.rb +3 -0
- data/app/models/analysis.rb +715 -0
- data/app/models/analysis_history.rb +42 -0
- data/app/models/cross_array.rb +22 -0
- data/app/models/cross_result.rb +254 -0
- data/app/models/derived_spatial_attribute.rb +3 -0
- data/app/models/diagram_cache.rb +16 -0
- data/app/models/diagram_cache_datum.rb +4 -0
- data/app/models/diagram_cache_session.rb +8 -0
- data/app/models/directory.rb +21 -0
- data/app/models/draw_method.rb +48 -0
- data/app/models/draw_method_attribute.rb +8 -0
- data/app/models/draw_parameter.rb +12 -0
- data/app/models/explorer_query.rb +354 -0
- data/app/models/explorer_result.rb +312 -0
- data/app/models/function.rb +75 -0
- data/app/models/function_argument.rb +6 -0
- data/app/models/function_output.rb +4 -0
- data/app/models/group.rb +153 -0
- data/app/models/image.rb +20 -0
- data/app/models/keyword_attribute.rb +179 -0
- data/app/models/knowledge.rb +94 -0
- data/app/models/knowledge_backup.rb +32 -0
- data/app/models/knowledge_figure.rb +16 -0
- data/app/models/knowledge_figure_backup.rb +16 -0
- data/app/models/knowledge_parser.rb +392 -0
- data/app/models/node.rb +605 -0
- data/app/models/node_entity_abstract.rb +112 -0
- data/app/models/node_lineage.rb +6 -0
- data/app/models/node_relation.rb +4 -0
- data/app/models/path_node.rb +60 -0
- data/app/models/query.rb +193 -0
- data/app/models/query_history.rb +12 -0
- data/app/models/results.rb +48 -0
- data/app/models/sign_up_user.rb +25 -0
- data/app/models/spatial_and_time_attribute.rb +11 -0
- data/app/models/user.rb +115 -0
- data/app/models/user_mailer.rb +48 -0
- data/app/models/value_type.rb +3 -0
- data/app/models/variable.rb +70 -0
- data/app/models/virtual_node.rb +457 -0
- data/app/views/analysis/__help_analysis_tab.en.html +57 -0
- data/app/views/analysis/__help_draw_share.en.html +12 -0
- data/app/views/analysis/__help_draw_tab.en.html +6 -0
- data/app/views/analysis/_analysis_function_settings.rhtml +61 -0
- data/app/views/analysis/_analysis_settings.rhtml +28 -0
- data/app/views/analysis/_diagram.rhtml +70 -0
- data/app/views/analysis/_dimension_option.rhtml +59 -0
- data/app/views/analysis/_draw_general_settings.rhtml +217 -0
- data/app/views/analysis/_draw_settings.rhtml +73 -0
- data/app/views/analysis/_history.rhtml +19 -0
- data/app/views/analysis/_popular_diagrams.rhtml +42 -0
- data/app/views/analysis/_save_form.rhtml +44 -0
- data/app/views/analysis/_variables.rhtml +66 -0
- data/app/views/analysis/_variables_order.rhtml +56 -0
- data/app/views/analysis/index.rhtml +195 -0
- data/app/views/analysis/preview.rhtml +3 -0
- data/app/views/analysis/save.rhtml +73 -0
- data/app/views/analysis/show_diagram.rhtml +42 -0
- data/app/views/cross/_display_map.rhtml +201 -0
- data/app/views/cross/_result.rhtml +205 -0
- data/app/views/cross/_show_result_tree.rhtml +40 -0
- data/app/views/cross/_show_results.rhtml +80 -0
- data/app/views/cross/_style.rhtml +21 -0
- data/app/views/cross/index.rhtml +271 -0
- data/app/views/draw_method/_edit_form.rhtml +110 -0
- data/app/views/draw_method/create.rhtml +8 -0
- data/app/views/draw_method/details.rhtml +113 -0
- data/app/views/draw_method/edit.rhtml +8 -0
- data/app/views/draw_method/list.rhtml +80 -0
- data/app/views/explorer/_display_map.rhtml +199 -0
- data/app/views/explorer/_show_result_tree.rhtml +40 -0
- data/app/views/explorer/_show_results.rhtml +101 -0
- data/app/views/explorer/_style.rhtml +21 -0
- data/app/views/explorer/index.rhtml +214 -0
- data/app/views/finder/_children.html.erb +84 -0
- data/app/views/finder/_children_details.html.erb +74 -0
- data/app/views/finder/_children_details_tr.html.erb +196 -0
- data/app/views/finder/create_tree.html.erb +15 -0
- data/app/views/finder/flex.html.erb +52 -0
- data/app/views/finder/index.html.erb +47 -0
- data/app/views/finder/show_details.html.erb +3 -0
- data/app/views/finder/show_images.html.erb +3 -0
- data/app/views/function/_edit_form.rhtml +106 -0
- data/app/views/function/create.rhtml +8 -0
- data/app/views/function/details.rhtml +96 -0
- data/app/views/function/edit.rhtml +8 -0
- data/app/views/function/list.rhtml +80 -0
- data/app/views/group/add_member.rhtml +13 -0
- data/app/views/group/change_owner.rhtml +15 -0
- data/app/views/group/create.rhtml +11 -0
- data/app/views/group/delete_member.rhtml +14 -0
- data/app/views/group/list.rhtml +63 -0
- data/app/views/knowledge/_backup.rhtml +135 -0
- data/app/views/knowledge/_category.rhtml +58 -0
- data/app/views/knowledge/_category_list.rhtml +34 -0
- data/app/views/knowledge/_category_table.rhtml +23 -0
- data/app/views/knowledge/_comment.rhtml +64 -0
- data/app/views/knowledge/_comment_input_form.rhtml +19 -0
- data/app/views/knowledge/_comments.rhtml +84 -0
- data/app/views/knowledge/_form.rhtml +139 -0
- data/app/views/knowledge/_group_figure_form.rhtml +187 -0
- data/app/views/knowledge/_layout_figure.rhtml +61 -0
- data/app/views/knowledge/_layout_figures_in_a_row_above_text.rhtml +42 -0
- data/app/views/knowledge/_layout_figures_under_text.rhtml +45 -0
- data/app/views/knowledge/_layout_one_figure_above_text.rhtml +28 -0
- data/app/views/knowledge/_summary.rhtml +21 -0
- data/app/views/knowledge/edit.rhtml +37 -0
- data/app/views/knowledge/list.rhtml +287 -0
- data/app/views/knowledge/new.rhtml +23 -0
- data/app/views/knowledge/new_from_analysis.rhtml +21 -0
- data/app/views/knowledge/show.rhtml +196 -0
- data/app/views/layouts/gfdnavi.rhtml +105 -0
- data/app/views/nodes/_ancestors.html.erb +89 -0
- data/app/views/nodes/_description_methods_table.html.erb +75 -0
- data/app/views/nodes/_mode.html.erb +16 -0
- data/app/views/nodes/description.html.erb +181 -0
- data/app/views/nodes/description_methods.html.erb +1 -0
- data/app/views/nodes/edit.html.erb +73 -0
- data/app/views/nodes/index.html.erb +25 -0
- data/app/views/nodes/show.html.erb +20 -0
- data/app/views/search/_children_details_mapsearch.rhtml +68 -0
- data/app/views/search/_children_details_tr.rhtml +205 -0
- data/app/views/search/_show_grouplist.rhtml +74 -0
- data/app/views/search/_show_results.rhtml +43 -0
- data/app/views/search/_show_results_global.rhtml +36 -0
- data/app/views/search/_show_results_partial.rhtml +39 -0
- data/app/views/search/_show_results_partial_groupbyfile.rhtml +50 -0
- data/app/views/search/_show_variablelist.rhtml +28 -0
- data/app/views/search/mapsearch.rhtml +176 -0
- data/app/views/search/remapsearch.rjs +18 -0
- data/app/views/search/show_details.rhtml +3 -0
- data/app/views/user/add_user.rhtml +30 -0
- data/app/views/user/change_password.rhtml +25 -0
- data/app/views/user/edit.html.erb +50 -0
- data/app/views/user/index.rhtml +162 -0
- data/app/views/user/login.rhtml +41 -0
- data/app/views/user/logout.rhtml +4 -0
- data/app/views/user/signup.rhtml +36 -0
- data/app/views/user/signup_succeeded.rhtml +36 -0
- data/app/views/user_mailer/authorization_inform.rhtml +15 -0
- data/app/views/user_mailer/signup_accepted.rhtml +12 -0
- data/app/views/user_mailer/signup_confirm.rhtml +14 -0
- data/app/views/user_mailer/signup_inform.rhtml +13 -0
- data/app/views/user_mailer/signup_rejected.rhtml +11 -0
- data/app/views/work_flow/_push_wsdls.rhtml +55 -0
- data/app/views/work_flow/index.rhtml +46 -0
- data/config/database.yml.example +35 -0
- data/config/environment.rb +68 -0
- data/config/gfdnavi.yml.example +95 -0
- data/config/load_config.rb +151 -0
- data/config/routes.rb +35 -0
- data/consistency_checker.rb +129 -0
- data/data/gfdnavi_docs/how_to_draw_multiple_images.knlge +68 -0
- data/data/gfdnavi_docs/how_to_knowledge.knlge +138 -0
- data/data/gfdnavi_docs/how_to_write_document_about_Gfdnavi.knlge +30 -0
- data/data/samples/jmadata.SIGEN +8 -0
- data/data/samples/jmadata.yml +6 -0
- data/data/samples/jmadata/MSM-P/2006.nc.yml +2 -0
- data/data/samples/jmadata/MSM-P/2006.yml +17 -0
- data/data/samples/jmadata/MSM-P/2006/0101.nc +0 -0
- data/data/samples/jmadata/MSM-P/2006/0101.nc.yml +13 -0
- data/data/samples/jmadata/MSM-P/2006/0102.nc +0 -0
- data/data/samples/jmadata/MSM-P/2006/0103.nc +0 -0
- data/data/samples/jmadata/MSM-P/2006/0104.nc +0 -0
- data/data/samples/jmadata/MSM-P/2006/0105.nc +0 -0
- data/data/samples/jmadata/MSM-P/2006/010[1-3].nc.yml +2 -0
- data/data/samples/jmadata/MSM-P/2006/skip_data.rb +96 -0
- data/data/samples/jmadata/MSM-P/2006/skip_data.sh +6 -0
- data/data/samples/reanalysis.SIGEN +8 -0
- data/data/samples/reanalysis/era40.SIGEN +8 -0
- data/data/samples/reanalysis/era40.yml +2 -0
- data/data/samples/reanalysis/era40/t.jan.nc +0 -0
- data/data/samples/reanalysis/era40/t.jan.nc.yml +1 -0
- data/data/samples/reanalysis/ncep.SIGEN +9 -0
- data/data/samples/reanalysis/ncep/T.jan.100hPa.png +0 -0
- data/data/samples/reanalysis/ncep/T.jan.100hPa.png.yml +43 -0
- data/data/samples/reanalysis/ncep/T.jan.nc +0 -0
- data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc +0 -0
- data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc.yml +8 -0
- data/data/samples/reanalysis/ncep/T.jan_only_root.nc +0 -0
- data/data/samples/reanalysis/ncep/T.jan_only_root.nc.yml +4 -0
- data/data/samples/reanalysis/ncep/UV.jan.nc +0 -0
- data/data/samples/reanalysis/ncep/UV.jan.nc.yml +10 -0
- data/data/samples/reanalysis/ncep/UV.jan.nc.yml.ja +11 -0
- data/data/samples/sonde_operational.yml +5 -0
- data/data/samples/sonde_operational/std_plev.yml +12 -0
- data/data/samples/sonde_operational/std_plev/41256.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/42410.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/43333.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/43346.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/48698.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/61641.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/63741.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/67083.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/72261.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/76805.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/82193.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/91165.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/91610.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/91948.spl.nc +0 -0
- data/data/samples/sonde_operational/std_plev/94294.spl.nc +0 -0
- data/db/NetCDFparser.rb +406 -0
- data/db/create_derived_spatial_attributes.sql +12 -0
- data/db/draw_methods/line.yml +6 -0
- data/db/draw_methods/scatter.yml +38 -0
- data/db/draw_methods/tone.yml +64 -0
- data/db/draw_methods/vector.yml +19 -0
- data/db/dump_db.rb +43 -0
- data/db/functions/additions.yml +10 -0
- data/db/functions/cut.yml +10 -0
- data/db/functions/division.yml +10 -0
- data/db/functions/mean.yml +28 -0
- data/db/functions/multiplication.yml +10 -0
- data/db/functions/stddev.yml +28 -0
- data/db/functions/subtraction.yml +10 -0
- data/db/migrate/001_initial_scheme.rb +289 -0
- data/db/migrate/002_add_open_id_authentication_tables.rb +20 -0
- data/db/register_directory_tree.rb +760 -0
- data/db/restore_db.rb +60 -0
- data/gfdnavi-install +828 -0
- data/install.rb +828 -0
- data/lib/activerecord_gfdnavi.rb +31 -0
- data/lib/basic_authorization.rb +50 -0
- data/lib/create_activeresources.rb +108 -0
- data/lib/execute_analysis.rb +472 -0
- data/lib/file_gfdnavi.rb +38 -0
- data/lib/gphys_gfdnavi.rb +81 -0
- data/lib/localdir.rb +110 -0
- data/lib/login_system.rb +110 -0
- data/lib/multibytes.rb +20 -0
- data/lib/narray_yaml.rb +58 -0
- data/lib/no_rdb_base.rb +40 -0
- data/lib/opendapdir.rb +171 -0
- data/lib/tar.rb +127 -0
- data/lib/tasks/clean.rake +65 -0
- data/lib/tasks/setup.rake +316 -0
- data/lib/tasks/update.rake +62 -0
- data/lib/vizshot_gfdnavi.rb +224 -0
- data/public/crossdomain.xml +4 -0
- data/public/flex/NodeTreeDescriptor.as +55 -0
- data/public/flex/TreeNode.as +253 -0
- data/public/flex/finder.mxml +304 -0
- data/public/flex/finder.swf +0 -0
- data/public/flex/gfdnavi.mxml +52 -0
- data/public/flex/gfdnavi.swf +0 -0
- data/public/images/Help_S-shots/dir_tree_with_add.jpg +0 -0
- data/public/images/analyze.gif +0 -0
- data/public/images/circle.gif +0 -0
- data/public/images/create_from_analysis_button.png +0 -0
- data/public/images/delete.png +0 -0
- data/public/images/down.png +0 -0
- data/public/images/drawbutton.gif +0 -0
- data/public/images/gfdnavi_home_logo.png +0 -0
- data/public/images/gfdnavi_logo_big.png +0 -0
- data/public/images/gfdnavi_logo_med.png +0 -0
- data/public/images/gfdnavi_logo_mini.png +0 -0
- data/public/images/gfdnavi_logo_nobg_big.png +0 -0
- data/public/images/gfdnavi_logo_nobg_med.png +0 -0
- data/public/images/gfdnavi_logo_nobg_small.png +0 -0
- data/public/images/gfdnavi_logo_small.png +0 -0
- data/public/images/gfdnavi_logo_xsmall.png +0 -0
- data/public/images/hbar.png +0 -0
- data/public/images/helpmark16.png +0 -0
- data/public/images/helpmark18.png +0 -0
- data/public/images/kikyu_g.gif +0 -0
- data/public/images/kikyu_r.gif +0 -0
- data/public/images/map_icon_g.gif +0 -0
- data/public/images/map_icon_r.gif +0 -0
- data/public/images/new_knowledge.png +0 -0
- data/public/images/openid.png +0 -0
- data/public/images/read_in_the_form.png +0 -0
- data/public/images/slider_f.gif +0 -0
- data/public/images/slider_f_red.gif +0 -0
- data/public/images/star1.gif +0 -0
- data/public/images/star2.gif +0 -0
- data/public/images/startanim.gif +0 -0
- data/public/images/stopanim.gif +0 -0
- data/public/images/tree/DL.png +0 -0
- data/public/images/tree/anal_viz.png +0 -0
- data/public/images/tree/analyze_visualize_checked_items.png +0 -0
- data/public/images/tree/binary.png +0 -0
- data/public/images/tree/details.png +0 -0
- data/public/images/tree/download_checked_items.png +0 -0
- data/public/images/tree/folder.png +0 -0
- data/public/images/tree/folder_close.gif +0 -0
- data/public/images/tree/image2.png +0 -0
- data/public/images/tree/knowledge.png +0 -0
- data/public/images/tree/knowledges.png +0 -0
- data/public/images/tree/last.gif +0 -0
- data/public/images/tree/last.png +0 -0
- data/public/images/tree/minus.gif +0 -0
- data/public/images/tree/minus_simple.gif +0 -0
- data/public/images/tree/none.gif +0 -0
- data/public/images/tree/none.png +0 -0
- data/public/images/tree/plus.gif +0 -0
- data/public/images/tree/plus_simple.gif +0 -0
- data/public/images/tree/show.png +0 -0
- data/public/images/tree/show_checked_items.png +0 -0
- data/public/images/tree/t.gif +0 -0
- data/public/images/tree/t.png +0 -0
- data/public/images/tree/tate.gif +0 -0
- data/public/images/tree/tate.png +0 -0
- data/public/images/up.png +0 -0
- data/public/images/vbar.png +0 -0
- data/public/images/white.bmp +0 -0
- data/public/images/x.gif +0 -0
- data/public/index.html +100 -0
- data/public/javascripts/AC_OETags.js +269 -0
- data/public/javascripts/analysis.js +751 -0
- data/public/javascripts/application.js +29 -0
- data/public/javascripts/directory_tree.js +102 -0
- data/public/javascripts/draw_method.js +83 -0
- data/public/javascripts/excanvas.js +704 -0
- data/public/javascripts/function.js +107 -0
- data/public/javascripts/gfdnavi.js +175 -0
- data/public/javascripts/knowledge.js +384 -0
- data/public/javascripts/mapsearch.js +313 -0
- data/public/javascripts/progress.js +42 -0
- data/public/javascripts/resizable_box.js +164 -0
- data/public/javascripts/slider.js +260 -0
- data/public/javascripts/tab.js +17 -0
- data/public/javascripts/work_flow.js +452 -0
- data/public/stylesheets/analysis.css +111 -0
- data/public/stylesheets/description.css +71 -0
- data/public/stylesheets/gfdnavi.css +141 -0
- data/public/stylesheets/knowledge.css +218 -0
- data/public/stylesheets/search.css +184 -0
- data/public/stylesheets/tree.css +45 -0
- data/public/stylesheets/tree_for_ie.css +3 -0
- data/public/stylesheets/work_flow.css +78 -0
- data/script/cleaner +11 -0
- data/script/server_ssl +131 -0
- data/test/fixtures/diagram_cache_data.yml +5 -0
- data/test/fixtures/diagram_cache_sessions.yml +6 -0
- data/test/fixtures/diagram_caches.yml +6 -0
- data/test/fixtures/directories.yml +57 -0
- data/test/fixtures/draw_parameters.yml +6 -0
- data/test/fixtures/function_arguments.yml +15 -0
- data/test/fixtures/function_outputs.yml +15 -0
- data/test/fixtures/functions.yml +29 -0
- data/test/fixtures/group_members.yml +33 -0
- data/test/fixtures/groups.yml +25 -0
- data/test/fixtures/images.yml +12 -0
- data/test/fixtures/keyword_attributes.yml +73 -0
- data/test/fixtures/knowledges.yml +10 -0
- data/test/fixtures/node_relations.yml +11 -0
- data/test/fixtures/nodes.yml +298 -0
- data/test/fixtures/sign_up_users.yml +8 -0
- data/test/fixtures/spatial_and_time_attributes.yml +29 -0
- data/test/fixtures/user_mailer/authorization_inform +11 -0
- data/test/fixtures/user_mailer/signup_accepted +10 -0
- data/test/fixtures/user_mailer/signup_confirm +17 -0
- data/test/fixtures/user_mailer/signup_inform +10 -0
- data/test/fixtures/user_mailer/signup_rejected +9 -0
- data/test/fixtures/users.yml +31 -0
- data/test/fixtures/value_types.yml +10 -0
- data/test/fixtures/variables.yml +17 -0
- data/test/functional/analysis_controller_test.rb +169 -0
- data/test/functional/description_controller_test.rb +18 -0
- data/test/functional/function_controller_test.rb +18 -0
- data/test/functional/group_controller_test.rb +18 -0
- data/test/functional/search_controller_test.rb +83 -0
- data/test/functional/user_controller_test.rb +77 -0
- data/test/functional/webservice_analysis_api_test.rb +12 -0
- data/test/functional/work_flow_controller_test.rb +18 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/diagram_cache_datum_test.rb +10 -0
- data/test/unit/diagram_cache_session_test.rb +10 -0
- data/test/unit/diagram_cache_test.rb +10 -0
- data/test/unit/directory_test.rb +49 -0
- data/test/unit/draw_parameter_test.rb +10 -0
- data/test/unit/function_argument_test.rb +10 -0
- data/test/unit/function_output_test.rb +10 -0
- data/test/unit/function_test.rb +10 -0
- data/test/unit/group_test.rb +48 -0
- data/test/unit/image_test.rb +13 -0
- data/test/unit/keyword_attribute_test.rb +33 -0
- data/test/unit/knowledge_test.rb +13 -0
- data/test/unit/node_relation_test.rb +20 -0
- data/test/unit/node_test.rb +85 -0
- data/test/unit/sign_up_user_test.rb +20 -0
- data/test/unit/spatial_and_time_attribute_test.rb +29 -0
- data/test/unit/user_mailer_test.rb +101 -0
- data/test/unit/user_test.rb +134 -0
- data/test/unit/value_type_test.rb +10 -0
- data/test/unit/variable_test.rb +35 -0
- data/vendor/plugins/acts_as_list/README +23 -0
- data/vendor/plugins/acts_as_list/init.rb +3 -0
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/vendor/plugins/acts_as_tree/README +26 -0
- data/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
- data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/vendor/plugins/will_paginate/CHANGELOG +92 -0
- data/vendor/plugins/will_paginate/LICENSE +18 -0
- data/vendor/plugins/will_paginate/README.rdoc +131 -0
- data/vendor/plugins/will_paginate/Rakefile +62 -0
- data/vendor/plugins/will_paginate/examples/apple-circle.gif +0 -0
- data/vendor/plugins/will_paginate/examples/index.haml +69 -0
- data/vendor/plugins/will_paginate/examples/index.html +92 -0
- data/vendor/plugins/will_paginate/examples/pagination.css +90 -0
- data/vendor/plugins/will_paginate/examples/pagination.sass +91 -0
- data/vendor/plugins/will_paginate/init.rb +1 -0
- data/vendor/plugins/will_paginate/lib/will_paginate.rb +86 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/array.rb +16 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +145 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +32 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +247 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +132 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +39 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/version.rb +9 -0
- data/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +373 -0
- data/vendor/plugins/will_paginate/will_paginate.gemspec +21 -0
- metadata +586 -0
|
File without changes
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'active_record'
|
|
5
|
+
|
|
6
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
7
|
+
require File.dirname(__FILE__) + '/../init'
|
|
8
|
+
|
|
9
|
+
class Test::Unit::TestCase
|
|
10
|
+
def assert_queries(num = 1)
|
|
11
|
+
$query_count = 0
|
|
12
|
+
yield
|
|
13
|
+
ensure
|
|
14
|
+
assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def assert_no_queries(&block)
|
|
18
|
+
assert_queries(0, &block)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
|
23
|
+
|
|
24
|
+
# AR keeps printing annoying schema statements
|
|
25
|
+
$stdout = StringIO.new
|
|
26
|
+
|
|
27
|
+
def setup_db
|
|
28
|
+
ActiveRecord::Base.logger
|
|
29
|
+
ActiveRecord::Schema.define(:version => 1) do
|
|
30
|
+
create_table :mixins do |t|
|
|
31
|
+
t.column :type, :string
|
|
32
|
+
t.column :parent_id, :integer
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def teardown_db
|
|
38
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
|
39
|
+
ActiveRecord::Base.connection.drop_table(table)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class Mixin < ActiveRecord::Base
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class TreeMixin < Mixin
|
|
47
|
+
acts_as_tree :foreign_key => "parent_id", :order => "id"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class TreeMixinWithoutOrder < Mixin
|
|
51
|
+
acts_as_tree :foreign_key => "parent_id"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class RecursivelyCascadedTreeMixin < Mixin
|
|
55
|
+
acts_as_tree :foreign_key => "parent_id"
|
|
56
|
+
has_one :first_child, :class_name => 'RecursivelyCascadedTreeMixin', :foreign_key => :parent_id
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class TreeTest < Test::Unit::TestCase
|
|
60
|
+
|
|
61
|
+
def setup
|
|
62
|
+
setup_db
|
|
63
|
+
@root1 = TreeMixin.create!
|
|
64
|
+
@root_child1 = TreeMixin.create! :parent_id => @root1.id
|
|
65
|
+
@child1_child = TreeMixin.create! :parent_id => @root_child1.id
|
|
66
|
+
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
|
67
|
+
@root2 = TreeMixin.create!
|
|
68
|
+
@root3 = TreeMixin.create!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def teardown
|
|
72
|
+
teardown_db
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_children
|
|
76
|
+
assert_equal @root1.children, [@root_child1, @root_child2]
|
|
77
|
+
assert_equal @root_child1.children, [@child1_child]
|
|
78
|
+
assert_equal @child1_child.children, []
|
|
79
|
+
assert_equal @root_child2.children, []
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_parent
|
|
83
|
+
assert_equal @root_child1.parent, @root1
|
|
84
|
+
assert_equal @root_child1.parent, @root_child2.parent
|
|
85
|
+
assert_nil @root1.parent
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_delete
|
|
89
|
+
assert_equal 6, TreeMixin.count
|
|
90
|
+
@root1.destroy
|
|
91
|
+
assert_equal 2, TreeMixin.count
|
|
92
|
+
@root2.destroy
|
|
93
|
+
@root3.destroy
|
|
94
|
+
assert_equal 0, TreeMixin.count
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_insert
|
|
98
|
+
@extra = @root1.children.create
|
|
99
|
+
|
|
100
|
+
assert @extra
|
|
101
|
+
|
|
102
|
+
assert_equal @extra.parent, @root1
|
|
103
|
+
|
|
104
|
+
assert_equal 3, @root1.children.size
|
|
105
|
+
assert @root1.children.include?(@extra)
|
|
106
|
+
assert @root1.children.include?(@root_child1)
|
|
107
|
+
assert @root1.children.include?(@root_child2)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_ancestors
|
|
111
|
+
assert_equal [], @root1.ancestors
|
|
112
|
+
assert_equal [@root1], @root_child1.ancestors
|
|
113
|
+
assert_equal [@root_child1, @root1], @child1_child.ancestors
|
|
114
|
+
assert_equal [@root1], @root_child2.ancestors
|
|
115
|
+
assert_equal [], @root2.ancestors
|
|
116
|
+
assert_equal [], @root3.ancestors
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_root
|
|
120
|
+
assert_equal @root1, TreeMixin.root
|
|
121
|
+
assert_equal @root1, @root1.root
|
|
122
|
+
assert_equal @root1, @root_child1.root
|
|
123
|
+
assert_equal @root1, @child1_child.root
|
|
124
|
+
assert_equal @root1, @root_child2.root
|
|
125
|
+
assert_equal @root2, @root2.root
|
|
126
|
+
assert_equal @root3, @root3.root
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_roots
|
|
130
|
+
assert_equal [@root1, @root2, @root3], TreeMixin.roots
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_siblings
|
|
134
|
+
assert_equal [@root2, @root3], @root1.siblings
|
|
135
|
+
assert_equal [@root_child2], @root_child1.siblings
|
|
136
|
+
assert_equal [], @child1_child.siblings
|
|
137
|
+
assert_equal [@root_child1], @root_child2.siblings
|
|
138
|
+
assert_equal [@root1, @root3], @root2.siblings
|
|
139
|
+
assert_equal [@root1, @root2], @root3.siblings
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_self_and_siblings
|
|
143
|
+
assert_equal [@root1, @root2, @root3], @root1.self_and_siblings
|
|
144
|
+
assert_equal [@root_child1, @root_child2], @root_child1.self_and_siblings
|
|
145
|
+
assert_equal [@child1_child], @child1_child.self_and_siblings
|
|
146
|
+
assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
|
|
147
|
+
assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
|
|
148
|
+
assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class TreeTestWithEagerLoading < Test::Unit::TestCase
|
|
153
|
+
|
|
154
|
+
def setup
|
|
155
|
+
teardown_db
|
|
156
|
+
setup_db
|
|
157
|
+
@root1 = TreeMixin.create!
|
|
158
|
+
@root_child1 = TreeMixin.create! :parent_id => @root1.id
|
|
159
|
+
@child1_child = TreeMixin.create! :parent_id => @root_child1.id
|
|
160
|
+
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
|
161
|
+
@root2 = TreeMixin.create!
|
|
162
|
+
@root3 = TreeMixin.create!
|
|
163
|
+
|
|
164
|
+
@rc1 = RecursivelyCascadedTreeMixin.create!
|
|
165
|
+
@rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
|
|
166
|
+
@rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
|
|
167
|
+
@rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def teardown
|
|
171
|
+
teardown_db
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_eager_association_loading
|
|
175
|
+
roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
|
|
176
|
+
assert_equal [@root1, @root2, @root3], roots
|
|
177
|
+
assert_no_queries do
|
|
178
|
+
assert_equal 2, roots[0].children.size
|
|
179
|
+
assert_equal 0, roots[1].children.size
|
|
180
|
+
assert_equal 0, roots[2].children.size
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
|
|
185
|
+
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
|
|
186
|
+
assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
|
|
190
|
+
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
|
|
191
|
+
assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
|
|
195
|
+
leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
|
|
196
|
+
assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
class TreeTestWithoutOrder < Test::Unit::TestCase
|
|
201
|
+
|
|
202
|
+
def setup
|
|
203
|
+
setup_db
|
|
204
|
+
@root1 = TreeMixinWithoutOrder.create!
|
|
205
|
+
@root2 = TreeMixinWithoutOrder.create!
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def teardown
|
|
209
|
+
teardown_db
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def test_root
|
|
213
|
+
assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_roots
|
|
217
|
+
assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
|
|
218
|
+
end
|
|
219
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
== master
|
|
2
|
+
|
|
3
|
+
* ActiveRecord 2.1: remove :include from count query when tables are not
|
|
4
|
+
referenced in :conditions
|
|
5
|
+
|
|
6
|
+
== 2.3.2, released 2008-05-16
|
|
7
|
+
|
|
8
|
+
* Fixed LinkRenderer#stringified_merge by removing "return" from iterator block
|
|
9
|
+
* Ensure that 'href' values in pagination links are escaped URLs
|
|
10
|
+
|
|
11
|
+
== 2.3.1, released 2008-05-04
|
|
12
|
+
|
|
13
|
+
* Fixed page numbers not showing with custom routes and implicit first page
|
|
14
|
+
* Try to use Hanna for documentation (falls back to default RDoc template if not)
|
|
15
|
+
|
|
16
|
+
== 2.3.0, released 2008-04-29
|
|
17
|
+
|
|
18
|
+
* Changed LinkRenderer to receive collection, options and reference to view template NOT in
|
|
19
|
+
constructor, but with the #prepare method. This is a step towards supporting passing of
|
|
20
|
+
LinkRenderer (or subclass) instances that may be preconfigured in some way
|
|
21
|
+
* LinkRenderer now has #page_link and #page_span methods for easier customization of output in
|
|
22
|
+
subclasses
|
|
23
|
+
* Changed page_entries_info() method to adjust its output according to humanized class name of
|
|
24
|
+
collection items. Override this with :entry_name parameter (singular).
|
|
25
|
+
|
|
26
|
+
page_entries_info(@posts)
|
|
27
|
+
#-> "Displaying all 12 posts"
|
|
28
|
+
page_entries_info(@posts, :entry_name => 'item')
|
|
29
|
+
#-> "Displaying all 12 items"
|
|
30
|
+
|
|
31
|
+
== 2.2.3, released 2008-04-26
|
|
32
|
+
|
|
33
|
+
* will_paginate gem is no longer published on RubyForge, but on
|
|
34
|
+
gems.github.com:
|
|
35
|
+
|
|
36
|
+
gem sources -a http://gems.github.com/ (you only need to do this once)
|
|
37
|
+
gem install mislav-will_paginate
|
|
38
|
+
|
|
39
|
+
* extract reusable pagination testing stuff into WillPaginate::View
|
|
40
|
+
* rethink the page URL construction mechanizm to be more bulletproof when
|
|
41
|
+
combined with custom routing for page parameter
|
|
42
|
+
* test that anchor parameter can be used in pagination links
|
|
43
|
+
|
|
44
|
+
== 2.2.2, released 2008-04-21
|
|
45
|
+
|
|
46
|
+
* Add support for page parameter in custom routes like "/foo/page/2"
|
|
47
|
+
* Change output of "page_entries_info" on single-page collection and erraneous
|
|
48
|
+
output with empty collection as reported by Tim Chater
|
|
49
|
+
|
|
50
|
+
== 2.2.1, released 2008-04-08
|
|
51
|
+
|
|
52
|
+
* take less risky path when monkeypatching named_scope; fix that it no longer
|
|
53
|
+
requires ActiveRecord::VERSION
|
|
54
|
+
* use strings in "respond_to?" calls to work around a bug in acts_as_ferret
|
|
55
|
+
stable (ugh)
|
|
56
|
+
* add rake release task
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
== 2.2.0, released 2008-04-07
|
|
60
|
+
|
|
61
|
+
=== API changes
|
|
62
|
+
* Rename WillPaginate::Collection#page_count to "total_pages" for consistency.
|
|
63
|
+
If you implemented this interface, change your implementation accordingly.
|
|
64
|
+
* Remove old, deprecated style of calling Array#paginate as "paginate(page,
|
|
65
|
+
per_page)". If you want to specify :page, :per_page or :total_entries, use a
|
|
66
|
+
parameter hash.
|
|
67
|
+
* Rename LinkRenderer#url_options to "url_for" and drastically optimize it
|
|
68
|
+
|
|
69
|
+
=== View changes
|
|
70
|
+
* Added "prev_page" and "next_page" CSS classes on previous/next page buttons
|
|
71
|
+
* Add examples of pagination links styling in "examples/index.html"
|
|
72
|
+
* Change gap in pagination links from "..." to
|
|
73
|
+
"<span class="gap">…</span>".
|
|
74
|
+
* Add "paginated_section", a block helper that renders pagination both above and
|
|
75
|
+
below content in the block
|
|
76
|
+
* Add rel="prev|next|start" to page links
|
|
77
|
+
|
|
78
|
+
=== Other
|
|
79
|
+
|
|
80
|
+
* Add ability to opt-in for Rails 2.1 feature "named_scope" by calling
|
|
81
|
+
WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2)
|
|
82
|
+
* Support complex page parameters like "developers[page]"
|
|
83
|
+
* Move Array#paginate definition to will_paginate/array.rb. You can now easily
|
|
84
|
+
use pagination on arrays outside of Rails:
|
|
85
|
+
|
|
86
|
+
gem 'will_paginate'
|
|
87
|
+
require 'will_paginate/array'
|
|
88
|
+
|
|
89
|
+
* Add "paginated_each" method for iterating through every record by loading only
|
|
90
|
+
one page of records at the time
|
|
91
|
+
* Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by
|
|
92
|
+
default
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Copyright (c) 2007 PJ Hyett and Mislav Marohnić
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
= WillPaginate
|
|
2
|
+
|
|
3
|
+
Pagination is just limiting the number of records displayed. Why should you let
|
|
4
|
+
it get in your way while developing, then? This plugin makes magic happen. Did
|
|
5
|
+
you ever want to be able to do just this on a model:
|
|
6
|
+
|
|
7
|
+
Post.paginate :page => 1, :order => 'created_at DESC'
|
|
8
|
+
|
|
9
|
+
... and then render the page links with a single view helper? Well, now you
|
|
10
|
+
can.
|
|
11
|
+
|
|
12
|
+
Some resources to get you started:
|
|
13
|
+
|
|
14
|
+
* Your mind reels with questions? Join our
|
|
15
|
+
{Google group}[http://groups.google.com/group/will_paginate].
|
|
16
|
+
* The will_paginate project page: http://github.com/mislav/will_paginate
|
|
17
|
+
* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs
|
|
18
|
+
* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51],
|
|
19
|
+
check it out.
|
|
20
|
+
|
|
21
|
+
== Installation
|
|
22
|
+
|
|
23
|
+
The recommended way is that you get the gem:
|
|
24
|
+
|
|
25
|
+
gem install mislav-will_paginate --source http://gems.github.com/
|
|
26
|
+
|
|
27
|
+
After that you don't need the will_paginate <i>plugin</i> in your Rails
|
|
28
|
+
application anymore. Just add a simple require to the end of
|
|
29
|
+
"config/environment.rb":
|
|
30
|
+
|
|
31
|
+
gem 'mislav-will_paginate', '~> 2.2'
|
|
32
|
+
require 'will_paginate'
|
|
33
|
+
|
|
34
|
+
That's it. Remember to install the gem on <b>all</b> machines that you are
|
|
35
|
+
deploying to.
|
|
36
|
+
|
|
37
|
+
<i>There are extensive
|
|
38
|
+
{installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
|
|
39
|
+
on {the wiki}[http://github.com/mislav/will_paginate/wikis].</i>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
== Example usage
|
|
43
|
+
|
|
44
|
+
Use a paginate finder in the controller:
|
|
45
|
+
|
|
46
|
+
@posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
|
|
47
|
+
|
|
48
|
+
Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
|
|
49
|
+
records. Don't forget to tell it which page you want, or it will complain!
|
|
50
|
+
Read more on WillPaginate::Finder::ClassMethods.
|
|
51
|
+
|
|
52
|
+
Render the posts in your view like you would normally do. When you need to render
|
|
53
|
+
pagination, just stick this in:
|
|
54
|
+
|
|
55
|
+
<%= will_paginate @posts %>
|
|
56
|
+
|
|
57
|
+
You're done. (Copy and paste the example fancy CSS styles from the bottom.) You
|
|
58
|
+
can find the option list at WillPaginate::ViewHelpers.
|
|
59
|
+
|
|
60
|
+
How does it know how much items to fetch per page? It asks your model by calling
|
|
61
|
+
its <tt>per_page</tt> class method. You can define it like this:
|
|
62
|
+
|
|
63
|
+
class Post < ActiveRecord::Base
|
|
64
|
+
cattr_reader :per_page
|
|
65
|
+
@@per_page = 50
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
... or like this:
|
|
69
|
+
|
|
70
|
+
class Post < ActiveRecord::Base
|
|
71
|
+
def self.per_page
|
|
72
|
+
50
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
|
|
77
|
+
But you can always specify the count explicitly when calling +paginate+:
|
|
78
|
+
|
|
79
|
+
@posts = Post.paginate :page => params[:page], :per_page => 50
|
|
80
|
+
|
|
81
|
+
The +paginate+ finder wraps the original finder and returns your resultset that now has
|
|
82
|
+
some new properties. You can use the collection as you would with any ActiveRecord
|
|
83
|
+
resultset. WillPaginate view helpers also need that object to be able to render pagination:
|
|
84
|
+
|
|
85
|
+
<ol>
|
|
86
|
+
<% for post in @posts -%>
|
|
87
|
+
<li>Render `post` in some nice way.</li>
|
|
88
|
+
<% end -%>
|
|
89
|
+
</ol>
|
|
90
|
+
|
|
91
|
+
<p>Now let's render us some pagination!</p>
|
|
92
|
+
<%= will_paginate @posts %>
|
|
93
|
+
|
|
94
|
+
More detailed documentation:
|
|
95
|
+
|
|
96
|
+
* WillPaginate::Finder::ClassMethods for pagination on your models;
|
|
97
|
+
* WillPaginate::ViewHelpers for your views.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
== Authors and credits
|
|
101
|
+
|
|
102
|
+
Authors:: Mislav Marohnić, PJ Hyett
|
|
103
|
+
Original announcement:: http://errtheblog.com/post/929
|
|
104
|
+
Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
|
|
105
|
+
|
|
106
|
+
All these people helped making will_paginate what it is now with their code
|
|
107
|
+
contributions or just simply awesome ideas:
|
|
108
|
+
|
|
109
|
+
Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence
|
|
110
|
+
Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs
|
|
111
|
+
van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel,
|
|
112
|
+
Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
== Usable pagination in the UI
|
|
116
|
+
|
|
117
|
+
There are some CSS styles to get you started in the "examples/" directory. They
|
|
118
|
+
are showcased in the <b>"examples/index.html"</b> file.
|
|
119
|
+
|
|
120
|
+
More reading about pagination as design pattern:
|
|
121
|
+
|
|
122
|
+
* Pagination 101:
|
|
123
|
+
http://kurafire.net/log/archive/2007/06/22/pagination-101
|
|
124
|
+
* Pagination gallery:
|
|
125
|
+
http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/
|
|
126
|
+
* Pagination on Yahoo Design Pattern Library:
|
|
127
|
+
http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination
|
|
128
|
+
|
|
129
|
+
Want to discuss, request features, ask questions? Join the
|
|
130
|
+
{Google group}[http://groups.google.com/group/will_paginate].
|
|
131
|
+
|