Skip to content

Instantly share code, notes, and snippets.

View SebbeJohansson's full-sized avatar

Sebastian Johansson SebbeJohansson

View GitHub Profile
@SebbeJohansson
SebbeJohansson / oldcURL.php
Last active September 26, 2018 08:40
cURL execution function. - Old version.
/**
* Execute a cURL.
*
* @param $url
* @param array $header An array of headers.
* @param string $mode Mode for the execution (PUT/GET/POST).
* @param string $variables Variables/body to send in execution. String or json.
* @return mixed Returns decoded json of return from execution.
*/
@SebbeJohansson
SebbeJohansson / clCurl.php
Created September 26, 2018 08:39
clCurl - Curl wrapper.
<?php
namespace Apex\Core;
class clCURLold {
public $oRequest;
public $iLastHTTPStatus;
public $aOptions = array();
<?php
$config = require('config.php');
$key = $config['secure_key'];
$uploadhost = $config['output_host'];
$uploadfolder = $config['output_folder'];
$redirect = $config['redirect_url'];
$giphy_key = $config['giphy_api_key'];
if ($_SERVER["REQUEST_URI"] == "/robot.txt") { die("User-agent: *\nDisallow: /"); }
$row = 1;
$keys = [];
$array = [];
if (($handle = fopen("themes/fritidsfabriken/docs/feature_value_export_CZ_en.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
//echo "<p> $num fields in line $row: <br /></p>\n";
$value = [];
for ($c=0; $c < $num; $c++) {
//echo $data[$c] . "<br />\n";
const regex = /(?<start><img)(?<middle>.*?)(?<end>\/>)/ig;
const newText = col.RichText.replaceAll(regex, (match, p1, p2, p3, offset, string, namedGroups) => {
return `${namedGroups.start} loading="lazy" ${namedGroups.middle} ${namedGroups.end}`;
});
import axios from "axios";
import StoryblokClient from "storyblok-js-client";
import TurndownService from "turndown";
import markdownConverter from "storyblok-markdown-richtext";
// rember to remove
const spaceId = {{INSERT STORYBLOK SPACE ID HERE}};
let Storyblok = new StoryblokClient({
// Remmber to remove
oauthToken: "{{INSERT STORYBLOK MANAGEMENT API TOKEN HERE}}",
@SebbeJohansson
SebbeJohansson / StoryblokDateTimeField.js
Last active July 23, 2022 16:53
A storyblok datetime field with a default value for today.
const Fieldtype = {
template: `
<div>
<div class="image__wrap uk-margin-small-bottom">
<input type="datetime-local" id="date" name="date" v-model="model.date">
</div>
</div>
`,
mixins: [window.Storyblok.plugin],
methods: {
@SebbeJohansson
SebbeJohansson / GithubGistEmbed.vue
Created August 30, 2022 21:22
Nuxt3 Github Gist Embed component
<script setup lang="ts">
const props = defineProps({
gistId: {
type: String,
required: true,
},
file: {
type: String,
required: false,
default: '',
@SebbeJohansson
SebbeJohansson / Text.vue
Created September 29, 2022 21:19
In-Line Storyblok block rendering for Nuxt3 with SSR and Prerendering
<script setup lang="ts">
import { Richtext } from 'storyblok-js-client';
const props = defineProps({ blok: Object });
const nuxtApp = useNuxtApp();
const textObject = { ...props.blok.text };
const nodes = [];
// Proof of concept for custom handling of inline blok nodes.
Object.entries(textObject.content).forEach(([key, node]) => {
if (node.type === 'blok') {
@SebbeJohansson
SebbeJohansson / StoryblokLiveEditorWithManualFetch.vue
Created October 21, 2022 14:18
Storyblok doesnt allow for Live Editor update on edit when doing a manual fetch without their functions, so this is how I handle it.
<script setup lang="ts">
import { StoryData } from '@storyblok/vue/dist';
const route = useRoute();
const isPreview = !!(route.query._storyblok && route.query._storyblok !== '');
const version = isPreview ? 'draft' : 'published';
const story = ref({} as StoryData);