diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE new file mode 100644 index 000000000..ca97bef32 --- /dev/null +++ b/.github/ISSUE_TEMPLATE @@ -0,0 +1,9 @@ +#### Do you want to request a *feature* or report a *bug*? + +#### What is the current behavior? + +*If the current behavior is a bug, please provide the steps to reproduce it and if possible a minimal demo of the problem via https://github.com/ or https://gist.github.com/* + +#### What is the expected behavior? + +#### Which versions of Ruby, Padrino, Sinatra, Rack, OS are you using? Did this work in previous versions? diff --git a/.gitmodules b/.gitmodules index 15e6255af..f33cef28a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,8 @@ [submodule "padrino-gen/lib/padrino-gen/generators/templates/static"] path = padrino-gen/lib/padrino-gen/generators/templates/static url = git://github.com/padrino/padrino-static.git + branch = master +[submodule "padrino-docs"] + path = padrino-docs + url = git://github.com/padrino/padrino-docs.git + branch = master diff --git a/.travis.yml b/.travis.yml index f27388a19..d852cc2d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,20 @@ -lang: ruby -before_install: gem install bundler --pre +language: ruby +sudo: false +cache: bundler +before_install: + - gem install bundler install: - - gem update --system - bundle update rvm: - - 1.9.3 - - 2.0.0 - - 2.1.1 + - 2.2.2 + - 2.3.0 + - 2.3.3 + - 2.4.3 + - 2.5.0 + - ruby-head - rbx-2 - jruby + - jruby-head notifications: irc: 'irc.freenode.org#padrino' recipients: @@ -24,11 +30,24 @@ notifications: branches: only: - master + - 0.12 + - 0.14 services: mongodb matrix: include: - - rvm: 2.1.1 + - rvm: 2.3.3 env: SINATRA_EDGE=true + - rvm: 2.3.3 + env: ERB_ENGINE=stdlib + - rvm: 2.3.3 + env: ERB_ENGINE=erubis + - rvm: 2.3.3 + env: HAML_ENGINE=hamlit + - rvm: 2.3.3 + env: AS_VERSION=3.2 allow_failures: - - rvm: 2.1.1 - env: SINATRA_EDGE=true + - rvm: rbx-2 + - rvm: jruby + - rvm: jruby-head + - rvm: ruby-head + - env: SINATRA_EDGE=true diff --git a/CHANGES.rdoc b/CHANGES.rdoc index f25a043c2..21cc9f6c6 100644 --- a/CHANGES.rdoc +++ b/CHANGES.rdoc @@ -1,5 +1,246 @@ = CHANGES +== 0.14.2 (2018-01-02) +- FIX router in non-Padrino applications (@adam12) +- FIX padrino-admin haml layout +- FIX Datamapper tasks (@adam12) +- FIX #1979 default test or spec task +- FIX #2150 refuse invalid database adapters +- FIX #2152 using open without requiring 'open-uri' +- NEW #2161 allow array as tag attribute (@aeris) +- FIX #2163 preserve spaces in args of padrino gen +- update Sequel usage +- update ActiveRecord::Migration usage (@adam12) + +== 0.14.1 (2017-05-16) +- FIX syntax error in ActiveRecord tasks (@sue445) +- NEW use hamlit if available in Gemfile + +== 0.14.0.2 (2017-05-08) +- FIX #2132 use Sinatra2 IndifferentHash if available + +== 0.14.0.1 (2017-03-23) +- FIX #2118 allow Logger without Extensions +- FIX #2128 do not render default layout in partials + +== 0.14.0 (2017-03-15) +- NEW #2120 enable cascading with Rack application (@namusyaka) +- FIX lock rake < 11.0 to avoid last_comment error (@namusyaka) +- FIX handle nil database passwords for create_db and drop_db (@phallstrom) +- FIX #2119 add rake gem tasks to gem project Rakefile +- NEW support Erubi ERB engine (@adam12) +- FIX #2125 do not load in cycle files excluded from reloading + +== 0.14.0.rc2 (2017-01-19) +- FIX #2109 change the format of session_id for Padrino Admin AccessControl +- WARN #2109 Existing sessions will be dropped +- FIX #2097 Use exe folder for application executables (@adam12) +- FIX #2105 Run bundle with --binstubs on -b switch (@adam12) +- FIX #2111 disallow conflicting project names +- NEW remove deprecations planned for 0.14.0 +- NEW stop managing Ruby default encodings + Default Encoding.default_internal is now nil (Ruby default) instead of UTF-8 (Padrino < 0.14 default) +- FIX #2113 properly override default values in route definitions if parameter is present (@fidalgo) +- FIX #2116 fix plugin list `padrino g plugin -l` (@fnordfish) + +== 0.14.0.rc1 (2016-11-02) +- NEW remove the requirement of ActiveSupport (export AS_VERSION=X.0 to put it back) + +== 0.13.3.3 (2016-11-02) +- FIX #2075 cache actual content_type mime type +- FIX #2081 remove -i option from pg_dump command (@dfens) +- FIX #2083 be able to create sqlite's file to deep tree of subdirectories (@kkarakawa) +- NEW dynamically list supported renderers (@jfredrickson) + +== 0.13.3.2 (2016-09-06) +- FIX #2071 regression of #1906 +- FIX running padrino without Gemfile +- NEW alias db:create for sequel adapter + +== 0.13.3.1 (2016-08-30) +- NEW support usage of partials without view path + +== 0.13.3 (August 17th 2016) + +- FIX #1785 Nested forms and helpers with ERB and Erubis (@ujifgc) +- FIX #1847 Shoulda on modern rubies +- NEW #1851 Remove RightJS, Riot, Steak support (@ujifgc) +- FIX #1872 Implement using partials without Sinatra (@ujifgc) +- NEW #1906 Allow shortened mailer render calls with default mailer and message names (@ujifgc) +- FIX #2013 Delegate padrino and padrino-gen to bundler binstubs (@ujifgc) +- FIX #2016 Escape urls in link_to and form_tag (@ujifgc) +- FIX #2042 Do not override access control object when registered in multiple apps (@nxs6) +- FIX #2045 Prevent overwriting params by given query (@namusyaka) +- NEW #2050 Update Moneta to 0.8.0 (@basex) +- FIX #2052 String#humanize compatibility with AS ~3.2 +- NEW #2056 Allow Pry as Padrino console shell +- FIX #2066 fix reloader with native jruby classes + +== 0.13.2 (May 9th 2016) + +- FIX #1789 Relax Tilt version to allow Tilt 2 (>= 1.4.1, < 3) (@ujifgc) +- WARN #1989 Warn about coming behavior change (@ujifgc) +- NEW #1987 Generator now failes with invalid namespace (@ujifgc) +- NEW Remove many internal uses of ActiveSupport (@ujifgc) +- FIX #2007 Respect Regexp#names at the time of route search (@namusyaka) +- FIX #2004 Set default alt attribute for image_tag (@namusyaka) +- FIX #2008 Login button on the admin app now looks as expected (@namusyaka) +- FIX #2011 Update mongoid database configuration (@serradura) +- FIX Remove empty rows and cols from textarea tag (@ujifgc) +- FIX #2015 Update broken links in the README and docs (@mariozig) +- FIX #2023 Preserve `default_builder` set in configure_apps (@ujifgc) +- FIX #2025 Match plugin names with dashes in their names (@wikimatze) +- WARN Notice about removing ObjectSpace.classes and ObjectSpace.new_classes in 0.14 (@ujifgc) +- FIX #2027 Use Module#name instead of Module#to_s (@namusyaka) +- NEW Logger option :sanitize_encoding (@ujifgc) +- FIX #2006 load missing AR models before calling seeds.rb (@ujifgc) +- NEW #1921 Adds `--api` option for project generator (@ujifgc) +- NEW #2032 Adds new `config/initializers` folder loaded during boot (@ujifgc) +- FIX #2019 Removes deprecation warning for ActiveRecord (@wikimatze) + +== 0.13.1 (January 17th 2016) + +- FIX #1978 Enable reloading of custom dependencies (@markglenfletcher) +- FIX Remove use of ActiveSupport in tests (@ujifgc) +- FIX #1982 Support nested query for expanding path (@namusyaka) +- FIX #1994 Missing new line in mocha generator (@peter50216) +- FIX #1995 Invalid german dates (@ujifgc) +- FIX #1998 Only output a warning message if the spec task is invoked (@postmodern) +- FIX #2000 Fix mutex handling for Ruby 2.3 (@tyabe) + +== 0.13.1.beta1 (October 18th 2015) + +- FIX #1975 Improve routing memory usage and performance (@namusyaka) +- FIX #1882 test for selected values for select tag (@ujifgc) +- FIX rendering exception for custom mime types (@nesquena) +- FIX relax mail gem dependency (@ujifgc) +- FIX minor doc typos (@lokyoung, @markglenfletcher) + +== 0.13.0 (October 11th 2015) + +- FIX #1614 Do not search for caller in bundler lib (@ujifgc) +- FIX #1796 Save and restore layout setting (@ujifgc) +- FIX #1882 Fix ambiguous selected items in "select_tag" (@nesquena) +- FIX #1965 Fail properly on wrong mailer name or message (@ujifgc) +- FIX #1959 simplify the mounter class (@dnesteryuk) +- FIX #1916 Check key existence on caching (@namusyaka) +- NEW #1946 Documentation fixes re default renderer is now none (@Quintasan) +- FIX #942 remove ar:auto:upgrade (@ujifgc) +- NEW #1919 allow configuring log file path +- FIX #1931 render partials in mail if padrino-helpers is available (@ujifgc) +- FIX #1950 Padrino now follows Sinatra's charset policy (@ujifgc) +- NEW #1909 Basic project configuration engine (@ujifgc) +- NEW #1966 sample benchmark test of padrino core (@ujifgc) + +== 0.13.0.beta3 (August 2nd 2015) + +- NEW #1908 Adds test-unit as a test component (@namusyaka) +- FIX #1829 add absolute_url to app methods, add :base_url setting (@ujifgc) +- FIX #1880 rendering issue by accepting string content types (@ujifgc) +- NEW #1898 Adds missing helpers for the input html element (@namusyaka) +- FIX AWS namespace in Dynamoid component (@namusyaka) +- FIX Root index route incorrectly matches single-character URLs (@namusyaka) +- NEW #1929 Alias db:migrate:down and db:migrate:up when using datamapper (@postmodern) +- FIX #1932 Replace ConnectionManagement with ConnectionPoolManagement (@namusyaka) +- FIX Restore AbstractFormBuilder#field\_human\_name (@namusyaka) +- FIX #1936 Don't echo password input (@namusyaka) +- NEW #1940 Add IdentityMap middleware to datamapper (@namusyaka) +- FIX Cache test for moneta (@ujifgc) +- FIX #1943 Issue with format provides in controller with wildcard accepts header (@ujifgc) +- FIX #1942 maintain Sinatra params indifference (@ujifgc) +- FIX properly reload classes without instances (@ujifgc) +- FIX #1922 consider methodless constants not external (@ujifgc) +- NEW #1945 adds community page to padrino-docs (@Quintasan) + +== 0.13.0.beta2 (April 11th 2015) + +* FIX #1870 Trigger filters if superclass responds to :filters (@namusyaka) +* FIX #749 Trigger resource dirtiness for datamapper (@ujifgc) +* NEW #1853 Adds wrapper for application which allows better extensibility (@namusyaka) +* FIX #1891 Refactorings for more reliable dependency loading (@hcatlin, @namusyaka) +* FIX Update rack-test to 0.6.3 and remove old patch (@ujifgc) +* FIX #1895 Use compass-blueprint gem for improved compass generator (@myokoym) +* FIX #1899 Upgrade to sinatra 1.4.6 and latest rack version (@namusyaka) +* FIX #1886 Moves rake task loading code later in the booting process (@namusyaka) + +== 0.13.0.beta1 (February 22nd 2015) + +* FIX cleanup and refactor rake tasks (@ujifgc) +* NEW Remove deprecated cache functionality (@minad) +* FIX Cleanup and improve test helpers for each gem (@ujifgc) +* FIX allow Padrino::Rendering with standard ERB (@ujifgc) +* NEW Emulate set method in mailer context (@ujifgc) +* FIX #1772 add button content tag to button_to block (@ujifgc) +* NEW #1133 switch default renderer to none (@ujifgc) +* FIX #1792 Faster code using reverse_each to iterate gems (@glaucocustodio) +* FIX #1793 Faster code using #sub instead of #gsub (@glaucocustodio) +* FIX #1795 load missing models for sq:seed (@ujifgc) +* NEW Use mustermann19 in all cases now (@namusyaka) +* FIX Remove abuse of force_encoding (@ujifgc) +* FIX #1811 Refactor and change style of path_router within core routing (@namusyaka) +* FIX #1803 Use relative paths for sqlite and sequel (@ujifgc) +* NEW #1800 Support named capture on regex for router (@namusyaka) +* FIX #1821 Don't load dependency files unless app's root is within Padrino root (@namusyaka) +* FIX Improved docs and FAQ for helpers and core (@fwolfst, @CrowdHailer, @seanhussey, @neilang) +* FIX #1835 Switch admin to sequel fixtures rather than datamapper (@namusyaka) +* FIX #1828 Refactor new router and fix sinatra compatibility (@namusyaka) +* FIX Ensure the before_filter is triggered in certain cases (@namusyaka) +* FIX Widen the range of `default_dependency_paths` (@namusyaka) +* NEW #1831 Implement the `mi:translate` task (@namusyaka) +* FIX #1852 ApplicationWrapper Prerequisite Issue (@hcatlin) +* FIX #1856 Skips loading models for the activerecord rake tasks (@namusyaka) +* NEW #1857 Precompile routes when loading Padrino (@namusyaka) +* NEW #1818 Implement `source_location` option for logger (@namusyaka) +* FIX #1859 Correct issues with the admin seeds generator (@Quintasan) +* FIX #1704 Make broken async stream callbacks work in Padrino (@jay2u) +* FIX #1862 Re-implement `PathRouter#recognize` (@namusyaka) +* FIX #863 Removes unsafe http_router patch (@namusyaka) +* FIX #1867 Update ShowExceptions to suit latest rack master (@namusyaka) +* FIX #1879 Improve access to Active Record Database Configuration (@scudelletti) +* DELETE remove deprecations (String#undent, #link_to with :fragment, old caching, + old form builder, rendering #fetch_template_file, #cache_template_file!, #resolved_layout, + Application#load_paths, Padrino.set_load_paths, Padrino.load_paths) +* FIX #1860 Padrino --environment switch now takes precedence over RACK_ENV environment variable +* FIX #1849 return proper exit codes in CLI + +== 0.12.5 (February 22nd 2015) + +* FIX #1794 inheritance of global prereqs (@ujifgc) +* FIX #1798 handling non-array `with` statement for params (@ujifgc) +* FIX Russian translation for password (@harrykiselev) +* FIX Prevent Padrino from overriding cache settings (@dariocravero) +* FIX sequence of execution for configuration methods in application (@namusyaka) +* FIX translations for admin for cs (@ortiga) +* FIX exception raised when running the controller generator (@namusyaka) +* FIX #1875 lock down rack to < 1.6.0 because of sinatra conflict (@ujifgc) + +== 0.12.4 (October 19th 2014) + +* FIX #1744 Corrects color support for Windows (@tyabe) +* FIX #1736 Regression with textarea helper (@ujifgc) +* FIX #1743 Add a padrino-gen generator for creating new Helpers (@dariocravero) +* FIX #1746 Avoid reloading the file if its path is not started with Padrino.root (@namusyaka) +* DELETE deprecated build_object method (@namusyaka) +* FIX #1752 Don't set the @_use_format variable when provides method is called (@namusyaka) +* FIX #48 Update mailer documentation and sample code (@postmodern) +* FIX #1752 Refactor routing code to avoid weird parameter (@namusyaka) +* FIX #1754 Adds end tags to admin erb template for index (@namusyaka) +* FIX #1749 Replace the AR::ConnectionManagement middleware with new middleware (@namusyaka) +* NEW #1756 Adds support for mysql2 gem in sql rake task helpers (@d6rkaiz) +* FIX #1761 Allow passing upcased string as the app name +* FIX #1776 improve params filtering for routes (@ujifgc) +* FIX #1778 Various YARD doc inconsistencies or errors (@claudiob) +* FIX #1765 Use controller's base path instead of constant name at controller test (@namusyaka) +* FIX #1781 Removes the default_filters method setting incorrect content-type (@namusyaka) +* FIX Sinatra compatibility for passing options to the static! method +* FIX #1585 Update HAML to pass tests by upgrading versions (@ujifgc) +* FIX #1782 make padrino-gen detect absolute paths on Windows (@ujifgc) +* FIX #1779 Use expanded path to request controller's content (@namusyaka) +* FIX Use yield and flatmap when possible to speed up performance (@ujifgc) +* NEW #1787 Mounter now supports Rack applications (@namusyaka) +* FIX #1788 exception that occurs when the free regex route exists (@namusyaka) +* NEW Merges the padrino-docs guides and content directly into the main repository (@ujifgc) + == 0.12.3 (August 13th 2014) * FIX #1579 Update admin deps such as font-awesome, jquery, bootstrap (@WaYdotNET) diff --git a/Gemfile b/Gemfile index 4cebc9455..fdf04f4cc 100644 --- a/Gemfile +++ b/Gemfile @@ -7,45 +7,56 @@ if ENV["AS_VERSION"] end group :db do - gem "dm-core", ">=1.2" - gem "dm-migrations", ">=1.2" - gem "dm-validations", ">=1.2" - gem "dm-aggregates", ">=1.2" - gem "dm-sqlite-adapter", ">=1.2" + gem "sequel" + gem "sqlite3", :platforms => [:mri, :rbx] + gem "jdbc-sqlite3", "~> 3.7.2", :platform => :jruby end group :development do - if ENV['SINATRA_EDGE'] + if ENV["SINATRA_VERSION"] + puts "=> Using Sinatra version ~> #{ENV['SINATRA_VERSION']}" + gem "sinatra", "~> #{ENV['SINATRA_VERSION']}" + elsif ENV['SINATRA_EDGE'] puts "=> Using sinatra edge" gem "sinatra", :git => "git://github.com/sinatra/sinatra.git" end - gem "nokogiri", "~> 1.5.10" + + gem "slim", ">= 1.3.0" + gem "liquid", ">= 2.1.1" + + if ENV['HAML_ENGINE'] == 'hamlit' + puts "=> Using Hamlit Haml engine" + gem "hamlit" + else + gem "haml", ">= 4.0.5" + end + + case ENV['ERB_ENGINE'] + when "stdlib" + puts "=> Using stdlib ERB engine" + when "erubis" + puts "=> Using Erubis ERB engine" + gem "erubis", ">= 2.7.0" + else + gem "erubi", ">= 1.6.0" + end + gem "rack", ">= 1.3.0" - gem "rake", ">= 0.8.7" + gem "rake", ">= 10.5.0" gem "yard", ">= 0.7.2" - gem "rack-test", ">= 0.5.0" + gem "rack-test", "~> 0.6.3" gem "fakeweb", ">= 1.2.8" - gem "webrat", ">= 0.5.1" - gem "haml", ">= 2.2.22" - gem "erubis", ">= 2.7.0" - gem "slim", ">= 1.3.0" - gem "builder", ">= 2.1.2" + gem "oga", "~> 2.5" + gem "builder", ">= 2.1.2" + gem "mocha", ">= 0.10.0" + gem "minitest", ">= 4.0" + platforms :jruby do gem "jruby-openssl" end - gem "mocha", ">= 0.10.0" - gem "minitest", ">= 4.0" end -%w[ - padrino - padrino-admin - padrino-cache - padrino-core - padrino-gen - padrino-helpers - padrino-mailer - padrino-support -].each do |dep| - gem dep, :path => File.expand_path('../' + dep, __FILE__) +load File.expand_path('../padrino/subgems.rb', __FILE__) +PADRINO_GEMS.each_key do |name| + gem name, :path => File.expand_path('../' + name, __FILE__) end diff --git a/README.rdoc b/README.rdoc index 0ae1c7702..35a1ead5d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -2,11 +2,14 @@ Padrino is the godfather of Sinatra. Follow us on {www.padrinorb.com}[http://padrinorb.com] and on twitter -{@padrinorb}[http://twitter.com/padrinorb] +{@padrinorb}[http://twitter.com/padrinorb]. Join us on {gitter}[https://gitter.im/padrino/padrino-framework] {Build Status}[http://travis-ci.org/padrino/padrino-framework] {Dependency Status}[https://gemnasium.com/padrino/padrino-framework] {}[https://codeclimate.com/github/padrino/padrino-framework] +{}[https://gitter.im/padrino/padrino-framework] +{Code Triagers Badge}[https://www.codetriage.com/padrino/padrino-framework] + == Preface Padrino is a ruby framework built upon the excellent {Sinatra Web Library}[http://www.sinatrarb.com]. @@ -34,58 +37,68 @@ Form Helpers:: Builder support such as: form_tag, form_for, field_set_tag, text_ Text Helpers:: Useful formatting like: time_ago_in_words, js_escape_html, sanitize_html. Mailer:: Fast and simple delivery support for sending emails (akin to ActionMailer). Caching:: Simple route and fragment caching to easily speed up your web requests. -Admin:: Builtin Admin interface (like Django) +Admin:: Built-in Admin interface (like Django) Logging:: Provide a unified logger that can interact with your ORM or any library. Reloading:: Automatically reloads server code during development. Localization:: Full support of I18n language localization and can auto-set user's locale. Keep in mind, developers are able to individually pull in these modular components -{into existing Sinatra applications}[http://www.padrinorb.com/guides/standalone-usage-in-sinatra] +{into existing Sinatra applications}[http://padrinorb.com/guides/advanced-usage/standalone-usage-in-sinatra/] or use them altogether for a full-stack Padrino application. == Installation -To install the padrino framework, simply grab the latest version from gemcutter: +To install the padrino framework, simply grab the latest version from {RubyGems}[https://rubygems.org]: $ gem install padrino This will install the necessary padrino gems to get you started. -Now you are ready to use this gem to enhance your sinatra projects or to create new Padrino applications. +Now you are ready to use this gem to enhance your Sinatra projects or to create new Padrino applications. For a more detailed look at installing Padrino, -check out the {Installation Guide}[http://www.padrinorb.com/guides/installation]. +check out the {Installation Guide}[http://padrinorb.com/guides/getting-started/installation/]. == Usage Padrino is a framework which builds on the existing functionality of Sinatra and provides a variety of -additional tools and helpers to build upon that foundation. This README and Padrino documentation in general will focus -on the enhancements to the core Sinatra functionality. To use Padrino, one should be familiar with the basic +additional tools and helpers to build upon that foundation. This README and Padrino documentation in general will focus on the enhancements to the core Sinatra functionality. To use Padrino, one should be familiar with the basic usage of Sinatra itself. -You can also check out the {Getting Started}[http://www.padrinorb.com/guides/getting-started] guide -to learn more about how Sinatra and Padrino work together. +You can also check out the {Why Learn Padrino?}[http://padrinorb.com/guides/introduction/why-learn-padrino/] introduction to learn more about how Sinatra and Padrino work together. -For information on how to use a specific gem in isolation within an existing Sinatra project, checkout the guide for -{Using Padrino within Sinatra}[http://www.padrinorb.com/guides/standalone-usage-in-sinatra]. +For information on how to use a specific gem in isolation within an existing Sinatra project, checkout the guide for {Using Padrino within Sinatra}[http://padrinorb.com/guides/advanced-usage/standalone-usage-in-sinatra/]. == Getting Started -Once a developer understands Sinatra, Padrino is quite easy to get comfortable with since Padrino is simply a superset -of existing sinatra functionality! +Once a developer understands Sinatra, Padrino is quite easy to get comfortable with since Padrino is simply a superset of existing Sinatra functionality! -First, be sure to read over the {Getting Started}[http://www.padrinorb.com/guides/getting-started] guide +First, be sure to read over the {Getting Started}[http://padrinorb.com/guides/getting-started/overview/] guide to learn more about how Sinatra and Padrino work together. Best way to learn more about building Padrino applications is to read following resources: -* {Padrino Guides}[http://www.padrinorb.com/guides] - Guides outlining the major functionality within Padrino. -* {Blog Tutorial}[http://www.padrinorb.com/guides/blog-tutorial] - Step-by-step guide to building a blog application with Padrino. -* {Padrino API}[http://www.padrinorb.com/api/index.html] - YARD documentation for the Padrino framework. -* {Quick Overview}[http://www.padrinorb.com/guides/basic-projects] - Outlines basic generation commands. +* {Padrino Guides}[http://padrinorb.com/guides] - Guides outlining the major functionality within Padrino. +* {Blog Tutorial}[http://padrinorb.com/guides/getting-started/blog-tutorial/] - Step-by-step guide to building a blog application with Padrino. +* {Padrino API}[http://www.rubydoc.info/github/padrino/padrino-framework] - YARD documentation for the Padrino framework. +* {Quick Overview}[http://padrinorb.com/guides/getting-started/basic-projects/] - Outlines basic generation commands. The individual Padrino sub-gems also contain README's which outlines their functionality. +== Further Questions + +Can't find an answer in the resources above? + +* Ask any questions on the {gitter channel}[https://gitter.im/padrino/padrino-framework]. + +== Bug reporting + +Log it onto Github by {creating a new issue}[http://github.com/padrino/padrino-framework/issues]. + +Be sure to include all relevant information, like the versions of Padrino, Rack, Sinatra, Ruby and operating system you are using. + +A minimal project showing the issue published on Github with Gemfile.lock is also extremely helpful. + == Copyright -Copyright (c) 2012-2013 Padrino. See LICENSE for details. +Copyright (c) 2010-2016 Padrino. See LICENSE for details. diff --git a/Rakefile b/Rakefile index 53c44ca32..3ea6b33d6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,26 +1,11 @@ # rake bump[X.X.X] && rake publish -require 'rubygems' unless defined?(Gem) -require 'fileutils' unless defined?(FileUtils) +require 'fileutils' require 'rake' -require 'yard' require File.expand_path("../padrino-core/lib/padrino-core/version.rb", __FILE__) -ROOT = File.expand_path(File.dirname(__FILE__)) -GEM_NAME = 'padrino-framework' - -padrino_gems = %w[ - padrino-core - padrino-support - padrino-helpers - padrino-mailer - padrino-cache - padrino-admin - padrino-gen - padrino-performance - padrino -] - -GEM_PATHS = padrino_gems.freeze +load File.expand_path('../padrino/subgems.rb', __FILE__) +GEM_PATHS = PADRINO_GEMS.keys +ROOT = File.expand_path(File.dirname(__FILE__)) def sh_rake(command) sh "#{Gem.ruby} -S rake #{command}", :verbose => true @@ -47,7 +32,7 @@ end desc "Clean pkg and other stuff" task :uninstall do - padrino_gems.each {|gem| + GEM_PATHS.each {|gem| system("gem uninstall #{gem} --force -I -x 2>/dev/null") } end @@ -70,11 +55,18 @@ end desc "Executes a fresh install removing all padrino version and then reinstall all gems" task :fresh => [:uninstall, :install, :clean] -desc "Pushes repository to GitHub" -task :push do - say "Updating and verifying submodules" +desc "Pulls latest commits and updates submodules" +task :pull do + say "Pulling latest commits" + sh "git checkout master" + sh "git pull origin master" + say "Updating submodules" sh "git submodule foreach git pull origin master" sh "ls padrino-gen/lib/padrino-gen/generators/templates/static/README.rdoc" +end + +desc "Pushes repository to GitHub" +task :push => :pull do say "Pushing to github..." sh "git tag #{Padrino.version}" sh "git push origin master" @@ -93,31 +85,24 @@ task :release => :publish desc "Run tests for all padrino stack gems" task :test do - # Omit the padrino metagem since no tests there - GEM_PATHS[0..-2].each do |g| + GEM_PATHS.each do |g| # Hardcode the 'cd' into the command and do not use Dir.chdir because this causes random tests to fail sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake test" end end -padrino_gems.each do |element| +GEM_PATHS.each do |element| desc "Run tests for #{element} component" task element.to_s do sh "cd #{element} && #{Gem.ruby} -S rake test" end end -desc "Run tests for all padrino stack gems" -task :default => :test - desc "Generate documentation for the Padrino framework" task :doc do + require 'yard' YARD::CLI::Yardoc.new.run end -desc "Publish doc on padrinorb.com/api" -task :pdoc => :doc do - say "Publishing doc on padrinorb.com ..." - sh "scp -r doc/* root@lps2.lipsiasoft.com:/mnt/www/apps/padrino/public/api/" - sh "rm -rf doc" -end +desc "Run tests for all padrino stack gems" +task :default => :test diff --git a/gem_rake_helper.rb b/gem_rake_helper.rb index 676e5c0bc..68e57e472 100644 --- a/gem_rake_helper.rb +++ b/gem_rake_helper.rb @@ -1,22 +1,21 @@ -require 'rubygems' unless defined?(Gem) -require 'rake' -require 'rake/testtask' +require 'bundler/setup' require 'bundler/gem_tasks' +require 'rake/testtask' require 'yard' # Skip the releasing tag class Bundler::GemHelper - def release_gem(*args) - guard_clean - built_gem_path = build_gem - rubygem_push(built_gem_path) + def version_tag + "#{version}" end end Rake::TestTask.new(:test) do |test| test.libs << 'test' + test.libs << '../padrino/test' test.test_files = Dir['test/**/test_*.rb'] test.verbose = true + test.warning = false end YARD::Rake::YardocTask.new diff --git a/load_paths.rb b/load_paths.rb deleted file mode 100644 index e02cead5c..000000000 --- a/load_paths.rb +++ /dev/null @@ -1,6 +0,0 @@ -if defined?(Gem) - gem 'bundler' -else - require 'rubygems' -end -require 'bundler/setup' diff --git a/padrino-admin/README.rdoc b/padrino-admin/README.rdoc index 7d77bf8cc..6a63931ba 100644 --- a/padrino-admin/README.rdoc +++ b/padrino-admin/README.rdoc @@ -13,7 +13,7 @@ Access Control:: Supports authentication and role permissions for your applicati === Admin Dashboard Usage For a complete look at usage of the Admin dashboard functionality, be sure to check out the -{Padrino Admin}[http://www.padrinorb.com/guides/padrino-admin] guide. +{Padrino Admin}[http://padrinorb.com/guides/features/padrino-admin/] guide. Create a new project: @@ -63,8 +63,8 @@ In this example +if+ we visit URLs that start with /+customer+/+orders+ or /+car to our :+login_page+ "/login". Once we are correctly logged in we can visit these pages. For a more complete look at using the Admin panel functionality and access features, be sure to check out the -{Padrino Admin}[http://www.padrinorb.com/guides/padrino-admin] guide. +{Padrino Admin}[http://padrinorb.com/guides/features/padrino-admin/] guide. == Copyright -Copyright (c) 2011-2013 Padrino. See LICENSE for details. +Copyright (c) 2011-2015 Padrino. See LICENSE for details. diff --git a/padrino-admin/Rakefile b/padrino-admin/Rakefile index 8e6cc7613..e682baf84 100644 --- a/padrino-admin/Rakefile +++ b/padrino-admin/Rakefile @@ -1,7 +1,3 @@ -# coding:utf-8 -RAKE_ROOT = __FILE__ - -require 'rubygems' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') namespace :bootstrap do diff --git a/padrino-admin/lib/padrino-admin.rb b/padrino-admin/lib/padrino-admin.rb index 983acf20f..97d1712bd 100644 --- a/padrino-admin/lib/padrino-admin.rb +++ b/padrino-admin/lib/padrino-admin.rb @@ -1,4 +1,3 @@ -require 'active_support/core_ext/array/conversions' require 'padrino-core' require 'padrino-helpers' diff --git a/padrino-admin/lib/padrino-admin/access_control.rb b/padrino-admin/lib/padrino-admin/access_control.rb index c9eb7fbcf..adc93d489 100644 --- a/padrino-admin/lib/padrino-admin/access_control.rb +++ b/padrino-admin/lib/padrino-admin/access_control.rb @@ -1,5 +1,3 @@ -require 'active_support/core_ext/class/attribute_accessors' - module Padrino module Admin class AccessControlError < StandardError @@ -14,12 +12,20 @@ class << self # def registered(app) app.register Padrino::Admin unless app.extensions.include?(Padrino::Admin) - app.set :session_id, "_padrino_#{File.basename(Padrino.root)}_#{app.app_name}".to_sym unless app.respond_to?(:session_id) + app.set :session_id, "_padrino_#{Padrino.env}_#{app.app_name}" unless app.respond_to?(:session_id) app.set :admin_model, 'Account' unless app.respond_to?(:admin_model) app.helpers Padrino::Admin::Helpers::AuthenticationHelpers app.helpers Padrino::Admin::Helpers::ViewHelpers app.before { login_required } - app.send(:cattr_accessor, :access_control) + app.class_eval do + class << self + attr_accessor :access_control + end + def access_control + self.class.access_control + end + end + app.send(:access_control=, Padrino::Admin::AccessControl::Base.new) end alias :included :registered @@ -57,7 +63,7 @@ def roles def project_modules(account) role = account.role.to_sym rescue :any authorizations = @authorizations.find_all { |auth| auth.roles.include?(role) } - authorizations.map(&:project_modules).flatten.uniq + authorizations.flat_map(&:project_modules).uniq end ## @@ -96,7 +102,7 @@ def project_modules(account) # = link_to 'Profile', url(:accounts, :edit, :id => current_account.id) # def allowed?(account=nil, path=nil) - path = "/" if path.blank? + path = "/" if path.nil? || path.empty? role = account.role.to_sym rescue nil authorizations = @authorizations.find_all { |auth| auth.roles.include?(:any) } allowed_paths = authorizations.map(&:allowed).flatten.uniq diff --git a/padrino-admin/lib/padrino-admin/generators/admin_app.rb b/padrino-admin/lib/padrino-admin/generators/admin_app.rb index 99204199c..7d70d4c5b 100644 --- a/padrino-admin/lib/padrino-admin/generators/admin_app.rb +++ b/padrino-admin/lib/padrino-admin/generators/admin_app.rb @@ -49,7 +49,7 @@ def create_admin tmp_ext = options[:renderer] || fetch_component_choice(:renderer) unless supported_ext.include?(tmp_ext.to_sym) - say "<= Your are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use -e haml or -e erb or -e slim", :yellow + say "<= You are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use #{supported_ext.map { |ext| '-e ' + ext.to_s }.join(' or ')}", :yellow raise SystemExit end @@ -76,7 +76,8 @@ def create_admin template "templates/app.rb.tt", destination_root(@admin_path + "/app.rb") inject_into_file destination_root('config/apps.rb'), "\nPadrino.mount(\"#{@app_name}::#{@admin_name}\", :app_file => Padrino.root('#{@admin_path}/app.rb')).to(\"/#{@admin_path}\")\n", :before => /^Padrino.mount.*\.to\('\/'\)$/ unless options[:destroy] - insert_middleware 'ActiveRecord::ConnectionAdapters::ConnectionManagement', @admin_path if [:minirecord, :activerecord].include?(orm) + insert_middleware 'ConnectionPoolManagement', @admin_path if [:minirecord, :activerecord].include?(orm) + insert_middleware 'IdentityMap', @admin_path if orm == :datamapper end params = [ @@ -134,6 +135,8 @@ def create_admin require_dependencies('bcrypt') end + require_dependencies 'activesupport', :version => ">= 3.1" + # A nicer select box. # TODO FIXME This doesn't make much sense in here. Review. # gsub_file destination_root("admin/views/#{@model_plural}/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles" diff --git a/padrino-admin/lib/padrino-admin/generators/templates/account/datamapper.rb.tt b/padrino-admin/lib/padrino-admin/generators/templates/account/datamapper.rb.tt index e4b18f27b..66a0e1ff5 100644 --- a/padrino-admin/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +++ b/padrino-admin/lib/padrino-admin/generators/templates/account/datamapper.rb.tt @@ -44,6 +44,11 @@ class <%= @model_name %> ::BCrypt::Password.new(crypted_password) == password end + def password=(password) + self.crypted_password = nil if password.present? + @password = password + end + private def password_required diff --git a/padrino-admin/lib/padrino-admin/generators/templates/account/seeds.rb.tt b/padrino-admin/lib/padrino-admin/generators/templates/account/seeds.rb.tt index 021807872..14948eeba 100644 --- a/padrino-admin/lib/padrino-admin/generators/templates/account/seeds.rb.tt +++ b/padrino-admin/lib/padrino-admin/generators/templates/account/seeds.rb.tt @@ -6,21 +6,22 @@ # shell.say name # email = shell.ask "Which email do you want use for logging into admin?" -password = shell.ask "Tell me the password to use:" +password = shell.ask "Tell me the password to use:", :echo => false shell.say "" -account = <%= @model_name %>.create(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin") +account = <%= @model_name %>.new(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin") if account.valid? + account.save shell.say "=================================================================" shell.say "<%= @model_name %> has been successfully created, now you can login with:" shell.say "=================================================================" shell.say " email: #{email}" - shell.say " password: #{password}" + shell.say " password: #{?* * password.length}" shell.say "=================================================================" else - shell.say "Sorry but some thing went wrong!" + shell.say "Sorry, but something went wrong!" shell.say "" account.errors.full_messages.each { |m| shell.say " - #{m}" } end diff --git a/padrino-admin/lib/padrino-admin/generators/templates/app.rb.tt b/padrino-admin/lib/padrino-admin/generators/templates/app.rb.tt index 79c33c4f0..23cabd307 100644 --- a/padrino-admin/lib/padrino-admin/generators/templates/app.rb.tt +++ b/padrino-admin/lib/padrino-admin/generators/templates/app.rb.tt @@ -1,3 +1,6 @@ +require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/string/inflections' + module <%= @app_name %> class <%= @admin_name %> < Padrino::Application register Padrino::Mailer diff --git a/padrino-admin/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt b/padrino-admin/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt index fd6a8dd20..d1036d1b7 100644 --- a/padrino-admin/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +++ b/padrino-admin/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt @@ -20,7 +20,7 @@ diff --git a/padrino-admin/lib/padrino-admin/generators/templates/erb/page/index.erb.tt b/padrino-admin/lib/padrino-admin/generators/templates/erb/page/index.erb.tt index b03ccb6e9..904a69b8b 100644 --- a/padrino-admin/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +++ b/padrino-admin/lib/padrino-admin/generators/templates/erb/page/index.erb.tt @@ -25,7 +25,7 @@ <%%= tag_icon :magic %>