text:
_global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_9 = {
    /**
     * Determines the elements to register for processing.
     *
     * Each element of the returned array can either be an element name, or "_top"
     * which is the top element of the tested code.
     *
     * @returns {Array} The list of elements.
     */
    register: function()
    {
        return ['a'];

    },

    /**
     * Process the registered element.
     *
     * @param {DOMNode} element The element registered.
     * @param {DOMNode} top     The top element of the tested code.
     */
    process: function(element, top)
    {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, 'Check that text of the link describes the purpose of the link.', 'H30');

    }
};


text:
id: 5a24c314108439a4d4036145
title: Mapear state para props
challengeType: 6
forumTopicId: 301433
dashedName: map-state-to-props
---

# --description--

O componente `Provider` permite que você forneça `state` e `dispatch` para seus componentes React, mas você deve especificar exatamente que state e actions deseja. Desta forma, você tem certeza que cada componente só tem acesso ao state de que precisa. Você consegue isso criando duas funções: `mapStateToProps()` e `mapDispatchToProps()`.

Nessas funções, você declara quais pedaços do state você quer ter acesso e quais criadores de ação você precisa ser capaz de despachar. Quando essas funções estiverem no lugar, você verá como usar o método `connect` do React Redux para conectá-los aos seus componentes em outro desafio.

**Observação:** nos bastidores, o React Redux usa o método `store.subscribe()` para implementar `mapStateToProps()`.

# --instructions--

Crie a função `mapStateToProps()`. Esta função deve receber `state` como um argumento, em seguida, retornar um objeto que mapeia esse state para nomes de propriedade específicos. Essas propriedades se tornarão acessíveis para o componente via `props`. Uma vez que esse exemplo mantém o estado inteiro do app em um único array, você pode passar todo o state para o seu componente. Cria uma propriedade `messages` no objeto que está sendo retornado e defina-a no `state`.

# --hints--

A const `state` deve ser um array vazio.

```js
assert(Array.isArray(state) && state.length === 0);
```

`mapStateToProps` deve ser uma função.

```js
assert(typeof mapStateToProps === 'function');
```

`mapStateToProps` deve retornar um objeto.

```js
assert(typeof mapStateToProps() === 'object');
```

Passar um array como state para `mapStateToProps` deve retornar esse array atribuído à chave `messages`.

```js
assert(mapStateToProps(['messages']).messages.pop() === 'messages');
```

# --seed--

## --seed-contents--

```jsx
const state = [];

// Change code below this line
```

# --solutions--

```jsx
const state = [];

// Change code below this line

const mapStateToProps = (state) => {
  return {
    messages: state
  }
};
```

redpajama_set_name: RedPajamaGithub


text:
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.impala.authorization;

import java.io.IOException;

import org.apache.hadoop.security.authentication.util.KerberosName;
import org.apache.impala.common.InternalException;
import org.apache.impala.common.RuntimeEnv;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;

/**
 * Class that represents a User of an Impala session.
 */
public class User {

  private final String name_;

  // Refer to BackendConfig.initAuthToLocal() for initialization
  // of static auth_to_local configs in KerberosName class.
  private final KerberosName kerberosName_;

  public User(String name) {
    Preconditions.checkNotNull(name);
    name_ = name;
    this.kerberosName_ = new KerberosName(name);
  }

  public String getName() { return name_; }

  public String getShortName() throws InternalException {
    try {
      return kerberosName_.getShortName();
    } catch (IOException e) {
      throw new InternalException(
          "Error calling getShortName() for user: " + getName(), e);
    }
  }

  /*
   * Returns the shortname for the user after applying auth_to_local
   * rules from string 'rules'. This is exposed for testing purposes only.
   * Ideally these rules are populated from hdfs configuration files.
   */
  @VisibleForTesting
  public String getShortNameForTesting(String rules) {
    Preconditions.checkNotNull(rules);
    Preconditions.checkState(RuntimeEnv.INSTANCE.isTestEnv());
    String currentRules = KerberosName.getRules();
    KerberosName.setRules(rules);
    String shortName = null;
    try {
      shortName = getShortName();
    } catch (InternalException e) {
      e.printStackTrace();
    }
    // reset the rules
    KerberosName.setRules(currentRules);
    return shortName;
  }

  @VisibleForTesting
  public static void setRulesForTesting(String rules) {
    Preconditions.checkState(RuntimeEnv.INSTANCE.isTestEnv());
    KerberosName.setRules(rules);
  }
}


text:
namespace mojo {
class ApplicationConnection;
}

namespace mash {
namespace browser_driver {

class BrowserDriverApplicationDelegate : public mojo::ApplicationDelegate,
                                         public mus::mojom::AcceleratorHandler {
 public:
  BrowserDriverApplicationDelegate();
  ~BrowserDriverApplicationDelegate() override;

 private:
  // mojo::ApplicationDelegate:
  void Initialize(mojo::ApplicationImpl* app) override;
  bool ConfigureIncomingConnection(
      mojo::ApplicationConnection* connection) override;

  // mus::mojom::AcceleratorHandler:
  void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override;

  void AddAccelerators();

  mojo::ApplicationImpl* app_;
  mojo::Binding<mus::mojom::AcceleratorHandler> binding_;

  DISALLOW_COPY_AND_ASSIGN(BrowserDriverApplicationDelegate);
};

}  // namespace browser_driver
}  // namespace mash

#endif  // MASH_BROWSER_DRIVER_BROWSER_DRIVER_APPLICATION_DELEGATE_H_


text:
using AutoMapper;
using Newtonsoft.Json;
using Piranha.Extend;
using Piranha.Extend.Serializers;
using Piranha.Runtime;
using Piranha.Security;
using System;
using System.Reflection;

namespace Piranha
{
    /// <summary>
    /// The main application object.
    /// </summary>
    public sealed class App
    {
        /// <summary>
        /// The singleton app instance.
        /// </summary>
        private static readonly App Instance = new App();

        /// <summary>
        /// Mutex for thread safe initialization.
        /// </summary>
        private readonly object _mutex = new object();

        /// <summary>
        /// The current state of the app.
        /// </summary>
        private bool _isInitialized = false;

        /// <summary>
        /// The currently registered blocks.
        /// </summary>
        private AppBlockList _blocks;

        /// <summary>
        /// The currently registered fields.
        /// </summary>
        private AppFieldList _fields;

        /// <summary>
        /// The currently registered modules.
        /// </summary>
        private AppModuleList _modules;

        /// <summary>
        /// The currently registered media types.
        /// </summary>
        private MediaManager _mediaTypes;

        /// <summary>
        /// The application object mapper.
        /// </summary>
        private IMapper _mapper;

        /// <summary>
        /// The application markdown converter.
        /// </summary>
        private IMarkdown _markdown;

        /// <summary>
        /// The currently registered serializers.
        /// </summary>
        private SerializerManager _serializers;

        /// <summary>
        /// The currently registered content types.
        /// </summary>
        private ContentTypeManager _contentTypes;

        /// <summary>
        /// The currently registered hooks.
        /// </summary>
        private HookManager _hooks;

        /// <summary>
        /// The currently registered permissions;
        /// </summary>
        private PermissionManager _permissions;

        /// <summary>
        /// The current cache level.
        /// </summary>
        private Cache.CacheLevel _cacheLevel = Cache.CacheLevel.Full;

        /// <summary>
        /// Gets the currently registered block types.
        /// </summary>
        public static AppBlockList Blocks => Instance._blocks;

        /// <summary>
        /// Gets the currently registered field types.
        /// </summary>
        public static AppFieldList Fields => Instance._fields;

        /// <summary>
        /// Gets the currently registred modules.
        /// </summary>
        public static AppModuleList Modules => Instance._modules;

        /// <summary>
        /// Gets the currently registered media types.
        /// </summary>
        public static MediaManager MediaTypes => Instance._mediaTypes;

        /// <summary>
        /// Gets the application object mapper.
        /// </summary>
        public static IMapper Mapper => Instance._mapper;

        /// <summary>
        /// Gets the markdown converter.
        /// </summary>
        public static IMarkdown Markdown => Instance._markdown;

        /// <summary>
        /// Gets the binding flags for retrieving a region from a
        /// strongly typed model.
        /// </summary>
        public static BindingFlags PropertyBindings =>
            BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

        /// <summary>
        /// Gets the currently registered serializers.
        /// </summary>
        public static SerializerManager Serializers => Instance._serializers;

        /// <summary>
        /// Gets the currently registered content types.
        /// </summary>
        public static ContentTypeManager ContentTypes => Instance._contentTypes;

        /// <summary>
        /// Gets the currently registered hooks.
        /// </summary>
        public static HookManager Hooks => Instance._hooks;

        /// <summary>
        /// Gets the currently registered permissions.
        /// </summary>
        public static PermissionManager Permissions => Instance._permissions;

        /// <summary>
        /// Gets/sets the current cache level.
        /// </summary>
        public static Cache.CacheLevel CacheLevel
        {
            get { return Instance._cacheLevel; }
            set { Instance._cacheLevel = value; }
        }

        /// <summary>
        /// Default private constructor.
        /// </summary>
        private App()
        {
            _blocks = new AppBlockList();
            _fields = new AppFieldList();
            _modules = new AppModuleList();
            _mediaTypes = new MediaManager();
            _serializers = new SerializerManager();
            _contentTypes = new ContentTypeManager();
            _hooks = new HookManager();
            _permissions = new PermissionManager();
        }

        /// <summary>
        /// Initializes the application object.
        /// </summary>
        public static void Init()
        {
            Instance.Initialize();
        }

        /// <summary>
        /// Serializes the given object.
        /// </summary>
        /// <param name="obj">The object to serialize</param>
        /// <param name="type">The type</param>
        /// <returns>The serialized object</returns>
        public static string SerializeObject(object obj, Type type)
        {
            var serializer = Instance._serializers[type];

            if (serializer != null)
                return serializer.Serialize(obj);
            return JsonConvert.SerializeObject(obj);
        }

        /// <summary>
        /// Deserializes the given value.
        /// </summary>
        /// <param name="value">The serialized value</param>
        /// <param name="type">The type</param>
        /// <returns>The deserialized object</returns>
        public static object DeserializeObject(string value, Type type)
        {
            var serializer = Instance._serializers[type];

            if (serializer != null)
                return serializer.Deserialize(value);
            return JsonConvert.DeserializeObject(value, type);
        }

        /// <summary>
        /// Initializes the application object.
        /// </summary>
        /// <param name="api">The current api</param>
        private void Initialize()
        {
            if (!_isInitialized)
            {
                lock (_mutex)
                {
                    if (!_isInitialized)
                    {
                        // Configure object mapper
                        var mapperConfig = new MapperConfiguration(cfg =>
                        {
                            cfg.CreateMap<Data.Alias, Data.Alias>()
                                .ForMember(a => a.Id, o => o.Ignore())
                                .ForMember(a => a.Created, o => o.Ignore());
                            cfg.CreateMap<Data.Category, Data.Category>()
                                .ForMember(c => c.Id, o => o.Ignore())
                                .ForMember(c => c.Created, o => o.Ignore());
                            cfg.CreateMap<Data.MediaFolder, Data.MediaFolder>()
                                .ForMember(f => f.Id, o => o.Ignore())
                                .ForMember(f => f.Created, o => o.Ignore())
                                .ForMember(f => f.Media, o => o.Ignore());
                            cfg.CreateMap<Data.MediaFolder, Models.MediaStructureItem>()
                                .ForMember(f => f.Level, o => o.Ignore())
                                .ForMember(f => f.Items, o => o.Ignore());
                            cfg.CreateMap<Data.Page, Models.PageBase>()
                                .ForMember(p => p.TypeId, o => o.MapFrom(m => m.PageTypeId))
                                .ForMember(p => p.Permalink, o => o.MapFrom(m => "/" + m.Slug))
                                .ForMember(p => p.Blocks, o => o.Ignore());
                            cfg.CreateMap<Models.PageBase, Data.Page>()
                                .ForMember(p => p.PageTypeId, o => o.MapFrom(m => m.TypeId))
                                .ForMember(p => p.Blocks, o => o.Ignore())
                                .ForMember(p => p.Fields, o => o.Ignore())
                                .ForMember(p => p.Created, o => o.Ignore())
                                .ForMember(p => p.LastModified, o => o.Ignore())
                                .ForMember(p => p.PageType, o => o.Ignore())
                                .ForMember(p => p.Site, o => o.Ignore())
                                .ForMember(p => p.Parent, o => o.Ignore());
                            cfg.CreateMap<Data.Page, Models.SitemapItem>()
                                .ForMember(p => p.MenuTitle, o => o.Ignore())
                                .ForMember(p => p.Level, o => o.Ignore())
                                .ForMember(p => p.Items, o => o.Ignore())
                                .ForMember(p => p.PageTypeName, o => o.Ignore())
                                .ForMember(p => p.Permalink, o => o.MapFrom(d => !d.ParentId.HasValue && d.SortOrder == 0 ? "/" : "/" + d.Slug));
                            cfg.CreateMap<Data.Param, Data.Param>()
                                .ForMember(p => p.Id, o => o.Ignore())
                                .ForMember(p => p.Created, o => o.Ignore());
                            cfg.CreateMap<Data.Post, Models.PostBase>()
                                .ForMember(p => p.TypeId, o => o.MapFrom(m => m.PostTypeId))
                                .ForMember(p => p.Permalink, o => o.MapFrom(m => "/" + m.Blog.Slug + "/" + m.Slug))
                                .ForMember(p => p.Blocks, o => o.Ignore());
                            cfg.CreateMap<Models.PostBase, Data.Post>()
                                .ForMember(p => p.PostTypeId, o => o.MapFrom(m => m.TypeId))
                                .ForMember(p => p.CategoryId, o => o.MapFrom(m => m.Category.Id))
                                .ForMember(p => p.Blocks, o => o.Ignore())
                                .ForMember(p => p.Fields, o => o.Ignore())
                                .ForMember(p => p.Created, o => o.Ignore())
                                .ForMember(p => p.LastModified, o => o.Ignore())
                                .ForMember(p => p.PostType, o => o.Ignore())
                                .ForMember(p => p.Blog, o => o.Ignore())
                                .ForMember(p => p.Category, o => o.Ignore())
                                .ForMember(p => p.Tags, o => o.Ignore());
                            cfg.CreateMap<Data.Site, Data.Site>()
                                .ForMember(s => s.Id, o => o.Ignore())
                                .ForMember(s => s.Created, o => o.Ignore());
                            cfg.CreateMap<Data.Site, Models.SiteContentBase>()
                                .ForMember(s => s.TypeId, o => o.MapFrom(m => m.SiteTypeId));
                            cfg.CreateMap<Models.SiteContentBase, Data.Site>()
                                .ForMember(s => s.SiteTypeId, o => o.Ignore())
                                .ForMember(s => s.InternalId, o => o.Ignore())
                                .ForMember(s => s.Description, o => o.Ignore())
                                .ForMember(s => s.Hostnames, o => o.Ignore())
                                .ForMember(s => s.IsDefault, o => o.Ignore())
                                .ForMember(s => s.Fields, o => o.Ignore())
                                .ForMember(s => s.Created, o => o.Ignore())
                                .ForMember(s => s.LastModified, o => o.Ignore());
                            cfg.CreateMap<Data.Tag, Data.Tag>()
                                .ForMember(t => t.Id, o => o.Ignore())
                                .ForMember(t => t.Created, o => o.Ignore());
                        });
                        mapperConfig.AssertConfigurationIsValid();
                        _mapper = mapperConfig.CreateMapper();

                        // Setup media types
                        _mediaTypes.Documents.Add(".pdf", "application/pdf");
                        _mediaTypes.Images.Add(".jpg", "image/jpeg");
                        _mediaTypes.Images.Add(".jpeg", "image/jpeg");
                        _mediaTypes.Images.Add(".png", "image/png");
                        _mediaTypes.Videos.Add(".mp4", "video/mp4");

                        // Compose content types
                        _contentTypes.Register<Models.IPage>("Page", "Page");
                        _contentTypes.Register<Models.IBlogPage>("Blog", "Archive", true);

                        // Compose field types
                        _fields.Register<Extend.Fields.CheckBoxField>();
                        _fields.Register<Extend.Fields.DateField>();
                        _fields.Register<Extend.Fields.DocumentField>();
                        _fields.Register<Extend.Fields.HtmlField>();
                        _fields.Register<Extend.Fields.ImageField>();
                        _fields.Register<Extend.Fields.MarkdownField>();
                        _fields.Register<Extend.Fields.MediaField>();
                        _fields.Register<Extend.Fields.NumberField>();
                        _fields.Register<Extend.Fields.PageField>();
                        _fields.Register<Extend.Fields.PostField>();
                        _fields.Register<Extend.Fields.StringField>();
                        _fields.Register<Extend.Fields.TextField>();
                        _fields.Register<Extend.Fields.VideoField>();

                        // Compose block types
                        _blocks.Register<Extend.Blocks.HtmlBlock>();
                        _blocks.Register<Extend.Blocks.HtmlColumnBlock>();
                        _blocks.Register<Extend.Blocks.ImageBlock>();
                        _blocks.Register<Extend.Blocks.QuoteBlock>();
                        _blocks.Register<Extend.Blocks.TextBlock>();

                        // Compose serializers
                        _serializers.Register<Extend.Fields.CheckBoxField>(new CheckBoxFieldSerializer<Extend.Fields.CheckBoxField>());
                        _serializers.Register<Extend.Fields.DateField>(new DateFieldSerializer());
                        _serializers.Register<Extend.Fields.DocumentField>(new DocumentFieldSerializer());
                        _serializers.Register<Extend.Fields.HtmlField>(new StringFieldSerializer<Extend.Fields.HtmlField>());
                        _serializers.Register<Extend.Fields.MarkdownField>(new StringFieldSerializer<Extend.Fields.MarkdownField>());
                        _serializers.Register<Extend.Fields.MediaField>(new MediaFieldSerializer());
                        _serializers.Register<Extend.Fields.NumberField>(new IntegerFieldSerializer<Extend.Fields.NumberField>());
                        _serializers.Register<Extend.Fields.PageField>(new PageFieldSerializer());
                        _serializers.Register<Extend.Fields.PostField>(new PostFieldSerializer());
                        _serializers.Register<Extend.Fields.StringField>(new StringFieldSerializer<Extend.Fields.StringField>());
                        _serializers.Register<Extend.Fields.TextField>(new StringFieldSerializer<Extend.Fields.TextField>());
                        _serializers.Register<Extend.Fields.ImageField>(new ImageFieldSerializer());
                        _serializers.Register<Extend.Fields.VideoField>(new VideoFieldSerializer());

                        // Create markdown converter
                        _markdown = new DefaultMarkdown();

                        // Register permissions
                        _permissions["Core"].Add(new PermissionItem
                        {
                            Name = Permission.PagePreview,
                            Title = "Page Preview"
                        });
                        _permissions["Core"].Add(new PermissionItem
                        {
                            Name = Permission.PostPreview,
                            Title = "Post Preview"
                        });

                        // Initialize all modules
                        foreach (var module in _modules)
                        {
                            module.Instance.Init();
                        }

                        _isInitialized = true;
                    }
                }
            }
        }
    }
}


text:
//
//  CMHTMLRenderer.h
//  MarkDownEditor
//
//  Created by Indragie on 1/20/15.
//  Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
//

#import <Foundation/Foundation.h>

@class CMDocument;

/**
 *  Renders HTML from a Markdown document.
 */
@interface CMHTMLRenderer : NSObject

/**
 *  Designated initializer.
 *
 *  @param document A Markdown document.
 *
 *  @return An initialized instance of the receiver.
 */
- (instancetype)initWithDocument:(CMDocument *)document;

/**
 *  Renders HTML from the Markdown document.
 *
 *  @return A string containing the HTML representation
 *  of the document.
 */
- (NSString *)render;

@end


text:
privacy}}">

        subject->present()->avatar }}" id="sidebarUserProfilePicture">

            {{trans('user::activities.created_object',['user' => $activity->subject->present()->fullname,])}}

                {{$activity->created_at->diffForHumans()}}