This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
bandolier-template/commands/lorem.js

74 lines
4.3 KiB

import { Media } from "../lib/models.js";
import { knex } from "../lib/ormish.js";
import slugify from "slugify";
export const description = "Adds lorem ipsum text.";
const delorean = [
"Uh, plutonium, wait a minute, are you telling me that this sucker's nuclear?",
"Oh, no no no, I never uh, I never let anybody read my stories.",
"George, buddy.",
"Remember that girl I introduced you to, Lorraine.",
"What are you writing?",
"Indeed I will, roll em.",
"I, Doctor Emmett Brown, am about to embark on an historic journey.",
"What have I been thinking of, I almost forgot to bring some extra plutonium.",
"How did I ever expect to get back, one pallet one trip I must be out of my mind.",
"What is it Einy?",
"Oh my god, they found me, I don't know how but they found me.",
"Run for it, Marty.",
"Don't worry.",
"Yeah. George. George.",
"Hey, George, buddy, you weren't at school, what have you been doing all day?",
"I haven't Uh, coast guard.",
"I think I know exactly what you mean.",
"Now that's a risk you'll have to take you're life depends on it.",
"Perfect, just perfect.",
"Okay, alright, Saturday is good, Saturday's good, I could spend a week in 1955.",
"I could hang out, you could show me around.",
"Wow, ah Red, you look great.",
"Everything looks great.",
"I still got time.",
"Oh my god.",
"No, no not again, c'mon, c'mon.",
];
const hipsum = "I'm baby taiyaki coloring book tacos mixtape church-key four dollar toast you probably haven't heard of them twee polaroid portland ennui +1 Artisan master cleanse shaman forage Shoreditch tacos pabst celiac hella cardigan tumeric truffaut neutra venmo beard you probably haven't heard of them 3 wolf moon vice Plaid cray taxidermy migas actually church-key street art PBR&B irony Glossier hot chicken pok pok +1 asymmetrical ennui snackwave unicorn messenger bag Pok pok farm-to-table humblebrag seitan artisan portland XOXO Church-key asymmetrical +1 palo santo tumblr trust fund flannel beard neutra skateboard banjo tonx Paleo iPhone hella fashion axe seitan hoodie unicorn knausgaard cronut post-ironic pug Banh mi keytar coloring book hot chicken tumeric health goth bespoke prism XOXO brooklyn gastropub enamel pin umami Slow-carb DIY lumbersexual sriracha vaporware direct trade fashion axe keffiyeh drinking vinegar cold-pressed next level Portland tattooed taiyaki tbh Cardigan normcore chicharrones man braid vape Pabst try-hard tofu craft beer bespoke asymmetrical Viral celiac mumblecore echo park jean shorts semiotics pitchfork lyft Cray sustainable scenester helvetica kombucha tumeric la croix blog waistcoat ethical art party squid slow-carb before they sold out Echo park meggings slow-carb stumptown cold-pressed godard fingerstache swag Succulents forage yuccie blog stumptown tote bag migas La croix readymade retro deep v taxidermy Cloud bread jianbing farm-to-table sriracha chartreuse pop-up taxidermy mixtape poutine Sartorial you probably haven't heard of them man braid tumblr Pop-up ugh hella hashtag thundercats art party artisan VHS skateboard yes plz church-key quinoa keytar VHS wolf small batch four dollar toast aesthetic mumblecore kombucha seitan poutine meditation heirloom Enamel pin plaid kinfolk subway tile Everyday carry street art organic direct trade VHS tattooed poke lumbersexual Kinfolk vinyl mixtape direct trade 90's kickstarter vexillologist jean shorts pop-up Dummy text More like dummy thicc text amirite".split(' ');
const random_element = (count, from) => {
const result = [];
for(let i = 0; i < count; i++) {
result.push(from[Math.floor(Math.random() * from.length)]);
}
return result;
}
const capitalize = (title) => {
return `${title[0].toUpperCase()}${title.slice(1)}`;
}
export const main = async () => {
const media = await Media.all({}, ["id"]);
for(let m of media) {
const title_length = Math.floor(Math.random() * 6) + 1;
const title_words = random_element(title_length, hipsum);
const title = title_words.map(t => capitalize(t)).join(' ');
const tag_words = random_element(title_length / 2, hipsum);
const tags = tag_words.map(t => "#" + slugify(t)).join(' ');
const desc = random_element(2, delorean).join(' ');
await Media.update({id: m.id}, {
title,
tags,
description: desc,
views: Math.floor(Math.random() * 100)
});
}
knex.destroy();
}