Autor: Mathias Lipowski

CocoaPod Workflow – eine Zusammenfassung

Eine auswführliche Beschreibung, wie man von Grund auf einen CocoaPod erstellt, findet sich unter https://guides.cocoapods.org/making/making-a-cocoapod.html. Ist der CocoaPod erstellt, dann lassen sich Updates mit wenigen Befehlen einpflegen. Hier nun die wichtigsten Schritte:

Zum Testen des Quelltextes:

$ pod lib lint

Vor dem Veröffentlichen zunächst die Versionsnummer anpassen. Dazu die .podspec bearbeiten:

# Versionsnummer anpassen
spec.version      = "0.0.1"
# Tag anpassen
spec.source       = { ... :tag => "0.0.1" }

Hinweis: wenn der Tag in spec.source als Variable angegeben wird, dann ist es nicht notwendig, diesen immer wieder anzupassen. Der Eintrag sollte dann so aussehen: :tag => "#{spec.version}"

Den Quelltext noch einmal prüfen:

$ pod lib lint

In Git einen Tag erstellen:

$ git add -A && git commit -m "Release 0.0.1."
$ git tag '0.0.1'
$ git push --tags

Die neue Version veröffentlichen:

$ pod trunk push NAME.podspec

Hinweise: gelegentlich werden von Xcode Meldungen (Notes) ausgegeben, die keine kritischen Fehler anzeigen, sondern nur einen Hinweis darstellen. Das kann dazu führen, dass eine Veröffentlichung fehlschlägt. Dann lässt sich eine Veröffentlichung mit dem Parameter --allow-warnings durchführen.

$ pod trunk push NAME.podspec --allow-warnings

Flickr emails out of control – they seem to be VERY excited to be acquired by SmugMug

On 20.04.2018, Flickr announced that they are excited to announce that Flickr has agreed to be acquired by SmugMug. That’s great, so let’s see what’s coming next!

But since this time this notification reached my inbox over and over again. In my case eight times per hour for 9 hours in a row (up to now, these are 61 mails in total). It seems that they left their office after sending the newsletter and do not watch what’s going on with their servers… Flickr, please stop this spook!! Who else has this problem? Or does somebody know someone who can stop this?

We’re excited to announce that Flickr has agreed to be acquired by SmugMug, the photography platform dedicated to visual storytellers.

Die interessantesten Podcasts: SEO, Content Marketing, Social Media, Startups

The Sience of Social Media

  soundcloud.com/the-science-of-social-media

The Science of Social Media is a podcast for marketers and brands interested in learning about new and exciting ways to implement social media marketing across a variety of platforms and industries. Join Buffer hosts Hailley, Brian, and Kevan each week as they interview some of the best marketers from brands and businesses that are leading the way in social media innovation and experimentation around the world. We promise to keep it fun, insightful, interesting, and most of all, actionable. The Science of Social Media is a podcast presented by the social media publishing and analytics tool, Buffer.

Detailed Content Marketing

  soundcloud.com/detailedcom

The aim of our podcast is simple: We want to bring you the best content marketing success stories the web has to offer, that you can actually use for marketing your own projects.
Each day at 7am New York Time (UTC-4) we’ll go live with a new episode so you can start your day with inspiration on what project to tackle next.

Baremetrics: Founder’s Journey and Startup-Tips

  soundcloud.com/baremetrics/sets/founders-journey
  soundcloud.com/baremetrics/sets/startup-tips

Read about (and listen to) true experiences, challenges, and what the road to success really looks like straight from the team behind Baremetrics.

Photo by Michael Mroczek on Unsplash

Customizing Bootstrap 4 without changing the core files

A simple instruction to customize the Bootstrap 4.0 using SASS and Autoprefixer.

But why? You can either…

  1. download the compiled version of Bootstrap or
  2. use the source of Bootstrap 4 and compile a custom version or
  3. use the CDN server

When you choose number 2, then it’s necessary to use SASS for compiling the style sheet and Autoprefixer for CSS vendor prefixing. And this is how to get a customized version of Bootstrap:

First make sure, you’ve installed Node.js and SASS.

Then create an empty folder my_directory with the following folders and some empty text files:

my_directory
+- node_modules [folder]
+- custom.scss
+- package.json

The node_modules folder is required for some node.js modules. custom.css will hold all your customized stylesheets and package.json is used for some node.js package settings. You will see this later.

Now it’s time to load the current version of Bootstrap. Download the source of Bootstrap 4 and extract the zip to the folder /node_modules/bootstrap/.

Point your terminal to my_directory and install some node.js modules with the following command:

npm install postcss-cli autoprefixer npm-run-all

Now you can open the custom.scss file and add some costumized styles. This file can look like this:

// Custom.scss

$mixable: #ca0027;

$colors: (
 "mixable": $mixable,
);
$theme-colors: (
 "primary": $mixable
);

// Required
@import "node_modules/bootstrap/scss/bootstrap";

In this simple example, we just set a new color and use this color as primary color. A more detailed description on how to customize your theme can be found in the Bootstrap docs.

Let’s say we have made all of our customizations, so let’s open the empty file package.json. Add the following lines, which are required to combine your custom stylesheet and the Bootstrap source:

{
  "scripts": {
    "style":"sass custom.scss | postcss --use autoprefixer -o custom.css",
    "style-min":"sass custom.scss --style compressed | postcss --use autoprefixer -o custom.min.css",
    "all":"npm-run-all --parallel style style-min"
  }
}

This file contains three scripts, which can be executed like this:

To create the output file custom.css:

npm run style

To create a compressed output file custom.min.css:

npm run style-min

And to create both files at once:

npm run all

That’s it. Keep in mind, that this will just compile the stylesheet. To compile the javascript, you should refer to the Bootstrap docs and the build tools there.

CakePHP 3: Benutzername oder Email zum Anmelden mit AuthComponent verwenden

In den Einstellungen der AuthComponent lässt sich festlegen, welches Feld der Datenbank für das Login verwendet werden soll. Hier kann allerdings nur ein einzelner Wert angegeben werden (bspw. username oder email). Um jedoch bei der Eingabe des Logins sowohl Benutzername, als auch Email zu erlauben, kann man die Einstellung zur Laufzeit (also beim Aufruf des Controllers) anpassen und das entsprechende Feld setzen. Und zwar wie folgt:

src/Controller/AppController.php

use Cake\Controller\Controller;

class AppController extends Controller
{
    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Flash');
        $this->loadComponent('Auth', [
            'authenticate' => [
                'Form' => [
                    'fields' => ['username' => 'username', 'password' => 'password'],
                ]
            ],
        ]);
    }
}

src/Controller/UsersController.php

use App\Controller\AppController;
use Cake\Validation\Validation;

class UsersController extends AppController
{
    public function login()
    {
        if ($this->request->is('post')) {

            if (Validation::email($this->request->getData('username'))) {
                $this->Auth->config('authenticate', [
                    'Form' => [
                        'fields' => ['username' => 'email']
                    ]
                ]);
                $this->Auth->constructAuthenticate();
                $this->request->data['email'] = $this->request->getData('username');
            }

            $user = $this->Auth->identify();

            if ($user) {
                $this->Auth->setUser($user);
                return $this->redirect($this->Auth->redirectUrl());
            }

            $this->Flash->error(__('Invalid combination of username/email and password.'));
        }
    }
}

src/Template/Users/login.ctp

<php
echo $this->Flash->render('auth');
echo $this->Form->create();

echo $this->Form->input('username');
echo $this->Form->input('password');

echo $this->Form->button(__('Login'));
echo $this->Form->end();
?>