Commit Graph

442 Commits

Author SHA1 Message Date
Vijay Dev
41231ef6c6 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
	activerecord/lib/active_record/type/value.rb
2014-08-19 16:28:53 +00:00
Rafael Mendonça França
d2d809868c Merge pull request #15889 from carnesmedia/model-name
Use #model_name on instances instead of classes
2014-08-17 23:01:13 -03:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
Kasper Timm Hansen
1e2ffe7ae6 Prepare for partial release.
- Default to Rails::DeprecatedSanitizer in ActionView::Helpers::SanitizeHelper.
- Add upgrade notes.
- Add sanitizer to new applications Gemfiles.
- Remove 'rails-dom-testing' as a dependency.
2014-08-17 19:25:47 +02:00
schneems
4d47220d7c Perf optimization for url_for called w/ Hash
Benchmarking the existing code:

```ruby
{ :only_path => options[:host].nil? }.merge!(options.symbolize_keys)) 
```

Against optimized code, that does not require a new hash or a merge:

```ruby
options = options.symbolize_keys
options[:only_path] = options[:host].nil? unless options.key?(:only_path)
options
```

We see a statistically significant performance gain:

![](https://www.dropbox.com/s/onocpc0zfw4kjxl/Screenshot%202014-08-14%2012.45.30.png?dl=1)

Updated to not mutate incoming parameters
2014-08-14 12:46:06 -05:00
Jeremy Kemper
dfc3f88311 Merge pull request #16438 from agrobbin/input-placeholder-i18n
Add I18n support for `:placeholder` HTML option is passed to form fields
2014-08-14 06:46:17 -07:00
Akira Matsuda
1a299b6ca6 Missing ActiveSupport require for calling String#first 2014-08-14 01:06:34 +09:00
Alex Robbin
8b02832500 add I18n support for :placeholder HTML option is passed to form fields 2014-08-12 23:11:43 -04:00
Rafael Mendonça França
a2400308ea Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/integration_test.rb
	actionview/CHANGELOG.md
2014-08-12 11:10:42 -03:00
Hendy Tanata
71c7fd1013 Uppercase HTML in docs.
[skip ci]
2014-08-08 14:27:05 -07:00
Akira Matsuda
3dfcae6afa defined? should actually work in current implementation
So this trick is not needed to be documented anymore.
2014-08-07 01:59:58 +09:00
Bogdan Gusiev
7a0c2ba48b Fixed #select form builder helper to support block with html output 2014-08-05 17:23:00 +03:00
Aaron Patterson
20a277c9a2 don't access named routes internals
just ask whether or not the route is defined
2014-07-30 15:27:20 -07:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.

Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.

Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.

The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.

Paired @sgrif & @schneems
2014-07-30 12:01:45 -05:00
Yves Senn
aade0a0412 docs, cleanup mixed indents within form_options_helper.rb RDoc.
[ci skip]

This fixes the broken code block rendering and indents the examples
within the parameter list.
2014-07-29 14:57:48 +02:00
David Heinemeier Hansson
da1b8a786c Fix that render layout should also be picked up by the template dependency tracker, but only half-ways. You can add that layout option on the same render call, and both templates should be added to the dependency tree. But thats going to require a more serious rework of the tracker. Please do help fix this part of it too. For now, render layout needs to be on its own line. 2014-07-25 16:37:18 -07:00
Eugene Gilburg
348de3a06e marking private methods which dont work if called on their own anyways 2014-07-18 20:54:30 -07:00
Eugene Gilburg
38117adfe3 small refactors to actionview renderers 2014-07-18 20:54:03 -07:00
Guo Xiang Tan
ee35b79d4c Prefer to pass block when logging.
The Logger by default includes a guard which checks for the
logging level. By removing the custom logging guards, we can decouple
the logging guard from the logging action to be done.

This also follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-07-18 15:04:43 +08:00
Yves Senn
246f07c751 docs, select and friends with multiple=true include a blank string.
[Jonas Baumann & Yves Senn]

The submitted params from a select with `multiple: true` look as follows:

```
{post: {category: [""]}}

{post: {category: ["", "Category 1", "Category 2"]}}
```

This is a follow up to #1552.
2014-07-17 17:28:58 +02:00
noinkling
f5d79d7650 Fix broken list formatting [ci skip] 2014-07-17 15:24:52 +12:00
Rafael Mendonça França
9bbb3ca306 Use &= instead of select with include?
The performance is almost the same with both implementations but this is
clear.

Before this patch:

Calculating -------------------------------------
  small erb template      1452 i/100ms
-------------------------------------------------
  small erb template    17462.1 (±13.3%) i/s -      85668 in   5.031395s
.Calculating -------------------------------------
small erb template with 1 partial
                           887 i/100ms
-------------------------------------------------
small erb template with 1 partial
                         8899.6 (±18.8%) i/s -      42576 in   5.009453s
.Calculating -------------------------------------
small erb template with 2 partials
                           666 i/100ms
-------------------------------------------------
small erb template with 2 partials
                         6821.5 (±8.8%) i/s -      33966 in   5.020791s

After the patch:

Calculating -------------------------------------
  small erb template      1479 i/100ms
-------------------------------------------------
  small erb template    15956.6 (±7.6%) i/s -      79866 in   5.036001s
.Calculating -------------------------------------
small erb template with 1 partial
                           841 i/100ms
-------------------------------------------------
small erb template with 1 partial
                         9242.2 (±6.9%) i/s -      46255 in   5.029497s
.Calculating -------------------------------------
small erb template with 2 partials
                           615 i/100ms
-------------------------------------------------
small erb template with 2 partials
                         6524.7 (±6.8%) i/s -      32595 in   5.020456s

You can find the benchmark code at
https://gist.github.com/rafaelfranca/dee31120cfdb1ddc3b56
2014-07-16 16:42:53 -03:00
Rafael Mendonça França
b5fbcc5d52 Merge pull request #15917 from luke-gru/actionview_perf
remove Set.new from DetailsKey::get, impacts rendering overhead
2014-07-16 16:14:42 -03:00
Rafael Mendonça França
d4df7ce7b3 Fix typo on the variable name 2014-07-16 14:59:55 -03:00
Rafael Mendonça França
7dc0f3fc8d Document the PartialIteration object 2014-07-16 14:54:23 -03:00
Rafael Mendonça França
9290fc5ce2 Build only one PartialIteration object for loop 2014-07-16 14:54:22 -03:00
Rafael Mendonça França
9830ebbeaf No need to have a file to PartialIteration class
This class is only used on the PartialRenderer.
2014-07-16 14:50:51 -03:00
Joel Junström
1f5b360466 Added PartialIteration class used when rendering collections
The iteration object is available as the local variable
"template_name_iteration" when rendering partials with collections.

It gives access to the +size+ of the collection beeing iterated over,
the current +index+ and two convinicence methods +first?+ and +last?+

"template_name_counter" variable is kept but is deprecated.

[Joel Junström + Lucas Uyezu]
2014-07-16 14:50:51 -03:00
Rafael Mendonça França
045d717316 Use the plugin API to the getter and setters
To avoid having to redefine these methods on the deprecated plugin we
should be using the sanitizer_vendor API.
2014-07-15 20:19:59 -03:00
Rafael Mendonça França
158a6dfcd2 We don't need loofah for the assertions
We can just use nokogiri
2014-07-15 13:40:21 -03:00
Rafael Mendonça França
04e7ea3e92 Merge pull request #16175 from skorks/log_digestor_as_debug
Log digest as :debug instead of :info
2014-07-15 11:12:27 -03:00
Andrew White
c3f4d6c8fe Merge pull request #16161 from jpawlyn/master
Fix empty host for an asset url when asset_host proc returns nil
2014-07-15 09:32:01 +01:00
Jolyon Pawlyn
d005777469 Return an absolute instead of relative path from an asset url in the case of the asset_host proc returning nil 2014-07-15 08:32:55 +01:00
Alan Skorkin
d92ade339c Log digest as :debug instead of :info 2014-07-15 14:18:32 +10:00
Santosh Wadghule
dfee0327b5 Fix typos like a html to an html and 'an mail' to 'an email'. [ci skip] 2014-07-14 00:14:47 +05:30
Rafael Mendonça França
3229eda00c Merge pull request #11218 from kaspth/loofah-integration
Loofah-integration

Conflicts:
	actionpack/CHANGELOG.md
	actionview/CHANGELOG.md
2014-07-10 16:52:00 -03:00
Carlos Antonio da Silva
05fde24e1e Include missing module in tag_helper
Since 6857415187810f1289068a448268264d0cf0844f we are using #safe_join to
join the content when an Array is given, so we must include the dependent
module here to make sure it's available when this module is used alone.

This was making Simple Form tests to fail with current master due to the
missing dependency.
2014-07-09 18:47:35 -03:00
Akshay Vishnoi
3ac3760c69 [ci skip] /javascript/ -> JavaScript - cover whole app 2014-07-04 03:00:09 +05:30
Rafael Mendonça França
2546610920 Use if/else
Since we are using both branches of the code is preferable to use
if/else over the early return.
2014-06-30 17:41:50 -03:00
Todd Bealmear
ac44345da3 Add String support for min/max attributes on DatetimeField 2014-06-30 17:39:50 -03:00
Robin Dupret
9ca0f8da2a Tiny documentation fixes [ci skip] 2014-06-29 20:15:28 +02:00
Max Kramer
4e1dc11283 Rename options param of #time_ago_in_words to match API change
Rename `include_seconds_or_options` to `options` to match 6b9356a (which removed the deprecation introduced by #6077).  This has no functional impact because the parameter is passed directly through, but makes it clearer that the parameter no longer supports a boolean as input.
2014-06-28 14:30:16 -04:00
Luke Gruber
4955c04eb6 remove Set.new from DetailsKey::get, impacts rendering overhead performance
Using ruby-prof, I noticed that Set#add had the largest 'self time'
percentage (5% of the overall time spent rendering) when
benchmarking the rendering of a small cached ERB template that was 3
lines long. It turns out it was from this line. I don't believe the
Set is necessary, either. Removing this line increases the rendering
ips using Benchmark::ips accordingly.
2014-06-25 23:18:33 -04:00
Amiel Martin
6b0e834a19 Use #model_name on instances instead of classes
This allows rails code to be more confdent when asking for a model name, instead of having to ask for the class.

Rails core discussion here: https://groups.google.com/forum/#!topic/rubyonrails-core/ThSaXw9y1F8
2014-06-24 17:20:24 -07:00
Gareth Rees
124f88eaa2 Deal with regex match groups in excerpt
Original implementation has bugs if the regex contains a match group.

Example:

    excerpt('This is a beautiful? morning', /\b(beau\w*)\b/i, :radius => 5)
    Expected: "...is a beautiful? mor..."
    Actual: "...is a beautifulbeaut..."

The original phrase was being converted to a regex and returning the text
either side of the phrase as expected:

    'This is a beautiful? morning'.split(/beautiful/i, 2)
    # => ["This is a ", "? morning"]

When we have a match with groups the match is returned in the array.

Quoting the ruby docs: "If pattern is a Regexp, str is divided where the
pattern matches. [...] If pattern contains groups, the respective matches will
be returned in the array as well."

    'This is a beautiful? morning'.split(/\b(beau\w*)\b/iu, 2)
    # => ["This is a ", "beautiful", "? morning"]

If we assume we want to split on the first match – this fix makes that
assumption – we can pass the already assigned `phrase` variable as the place
to split (because we already know that a match exists from line 168).

Originally spotted by Louise Crow (@crowbot) at
https://github.com/mysociety/alaveteli/pull/1557
2014-06-24 17:01:40 +01:00
Rafael Mendonça França
0e09875a67 Merge pull request #15732 from kuldeepaggarwal/correct-assets-ouput
[ci skip] correct output for asset_helper methods
2014-06-23 14:41:40 -03:00
Rafael Mendonça França
d4ca0a44c7 Merge pull request #15450 from aditya-kapoor/remove-nbsp-debug
remove unnecessary gsub for space in ActionView::Helpers#debug
2014-06-19 16:43:47 -03:00
Lucas Mazza
9f27e1076a 'TextHelper#highlight' now accepts a block to highlight the matched words.
The helper will yield each matched word, and you can use this instead of the
':highlighter' option for more complex replacing logic:

  highlight('My email is me@work.com', EMAIL_REGEXP) { |m| mail_to(m) }
  # => 'My email is <a href="mailto:me@work.com">me@work.com</a>'
2014-06-19 15:22:23 -03:00
Jan Szumiec
490f25034d highlight() now accepts regular expressions as well. 2014-06-19 14:53:18 -03:00
Jan Szumiec
2b617783ad excerpt() now accepts regular expression instances as phrases. 2014-06-19 14:44:59 -03:00