Updating a 10 year old Laravel post

In November of 2012, I had a short blog post about using Laravel (at the time v3) with the Redactor javascript code for wysiwyg textareas. It’s not bad, but could use an update.

First, I see “classic” Redactor is deprecated in favor of Redactor X, and they want you to pay for it. Since I don’t plan on actually using, I’m going to assume the docs work as expected. Second, Laravel is now on version 9, which is a long way from version 3. Though interestingly, the syntax is not that wildly different.

Begin by updating initial route, now located in “/routes/web.php”. Instead of the View facade, we can do this:

Route::get('redactor', function() {
    return view('redactor');
});

Easy! We could’ve left it as is, since View::make() still works (!!!) but this is a bit nicer.

Next, we can update the HTML for that view. In the original, it was using a non-Blade view which is a bit silly in 2022. Also, the Form facade was removed from Laravel in version 5, so you either use plain-old HTML form tags, or the HTML package from Laravel Collective, which is what I did.

<!DOCTYPE html>
<html>
   <head>     
         <title>Laravel 9 and Redactor</title>
         <meta charset="utf-8">
         <link rel="stylesheet" href="css/redactorx.min.css" />
   </head>
   <body>
         {!! Form::open() !!}
         {!! Form::label('mytext', 'My Text') }
         <br>
         {!! Form::textarea('mytext', '', ['id' => 'mytext']) !!}
         <br>
         {!! Form::submit('Send it!') !!}
         {!! Form::close() !!}
         <script src="js/redactorx.min.js"></script>
         <script type="text/javascript">
                RedactorX('#mytext', {
                    image: {
                        upload: '/redactorupload/'
                    }
                });
         </script>
   </body>
</html>

No more jQuery and fancy Blade code!

Then we update the route that will accept the upload, and again, it’s still pretty close to the original:

Route::post('redactorupload', function(Request $request) {
    $validation = Validator::make($request->all(), [
        'file' => 'image|max:10000'
    ]);

    if ($validation->fails()) {
        return false;
    }

    $filePath = $request->file('file')->store('public/images');
    if (empty($filePath)) {
        return false;
    }

    return response()->json(['filelink' => Storage::url($path)]);
});

The biggest difference is the Input facade was removed in favor of using the Request object in the closure. I also removed an unneeded else statement.

The final bit of code was simply echoing out the form input if you submitted it. Instead of doing a dd() (which still works), we can update it like so:

Route::post('redactor', function(Request $request) {
    return $request->all();
});

That’s it. Now we have updated some 10 year old code!

Laracon: Saturday. 1st Laravel Conference in (others’) Pictures.

Morning in Washington DC

 

 



 

Aaron Kuzemchak : Simple API Development

Demo

 

 

 



 

Dayle Rees : Laravel: An Unexpected Journey

 

 

 



 

Zack Kitzmiller : Procrastinating Code

 

 

 



 

Jonathan Barronville : Vagrant, Puppet, Laravel & You

 

 

 



 

Eric Barnes : The Care and Feeding of a Robot

 

 

 



 

Shawn McCool : Running a Small Business on Laravel

 

 

 



 

Taylor Otwell : Eloquence Evolving

 

There were some awesome talks here at #Laracon. Looking forward to the next!

Links to Unemployment signup page for each state

At SXSW, I spent a couple of the days at the sessions dealing with government topics.  One of the things that was brought up quite a bit was that State websites are almost universally horrible.  They’re poorly designed and finding information easily is near impossible.  Utah is one exception to this rule, but really, it’s just about the ONLY exception.

I decided to try and find the Unemployment signup pages for a couple of states, just to see how easy or difficult it was.  It was NOT easy.  I remember a couple of years ago, when I was laid off, getting to the Texas unemployment online signup was full of twists and turns, and pages of descriptions and explanation. I just wanted to go to the signup page.  So I decided to create a simple page with links to the unemployment signup pages for each state… hopefully skipping all the explanations and description pages.

As I was searching for each state, I was surprised at how outdated the sites were. So many required Internet Explorer, and a couple prevented me from even accessing the pages using Chrome.  And Pennsylvania… Netscape Navigator? Really? Well, it IS using classic ASP… so I guess it is to be expected.

I think I may do this for other commonly needed pages, too.  In one of the sessions, someone mentioned how difficult it was to find info about building permits… but since that gets into county and city pages, it may be beyond the scope of this project. I just need to figure out what pages are most commonly needed.

Terry’s Happy Place songs

There are songs that just seem to always make you feel better when you hear them.  I’ve kept my own list in my head, and now I want to collect them into one post.  The list is fluid, but most of these have been set for years.  In no particular order, songs that put a smile on my face:

1) Morningwood – Nth Degree

2) Frankie Valli – December, 1963 (Oh, What a Night)

3) Glass Tiger – Don’t Forget Me When I’m Gone

4) Dolly Parton – Here You Come Again

5) Duran Duran – Hold Back The Rain

6) Duran Duran – The Reflex (yes, 2 Duran Duran songs)

7) The Beatles – Good Morning Good Morning (pretty much any Beatles, though)

8) Public Image Ltd – Disappointed

9) Radiohead – Bones

Fun puzzle – Christmas Conundrum

Saw this puzzle on Chris Shiflett’s blog and was able to figure it out. Don’t read further if you want to try yourself…

 

 

 

 

First, I wrote down the numbers, and immediately noticed the first numbers “1024” and “512” were suspiciously binary… though, that seems somewhat coincidental now. However, I plotted all the numbers into a spreadsheet, then did a conversion to binary.  I began thinking that maybe the 1s and 0s were like the beat of a Christmas song, so I tapped them out, and it didn’t seem to be anything.  Though bits seemed to be like “Jingle Bells” or “God Rest Ye Merry Gentlemen”, they never played out for the entire song. I got a bit sidetracked, thinking this was a designer, that maybe the numbers should be converted to HEX values, and use those colors for something.  Again, it didn’t pan out.  Here’s where I was at that point:

Then, as I looked at the column of binary numbers, I noticed there was a pattern… not in the numbers, but in the shape of the groups of numbers. I converted the column to monospace type and started connecting the 1s. It really didn’t make sense at first… but I saw the last group of numbers made a Greek Sigma “Σ” and an “X”. So I thought “Sigma Chi”, a fraternity.  The numbers above it made a “W” and a Sigma, and I thought maybe the “W” was supposed to be a Psi, but I couldn’t find anything relevant for “Psi Sigma”. At that point, I hadn’t connected all the 1s correctly, so I went back and connected all the 1s, even diagonally. The patterns became a lot clearer… but it still didn’t make sense.  At that point, I had my table turned just a bit to the side, and noticed the Sigma could actually be a sideways “M” and the “W” a sideways “E”… so I had “E M M X”.  With that, I saw I already had the “A” and a “Y”. Once I made one more missed connection of 1s, I had the two “R”s and figured the extra bit in the first group was an “!”.  From there, it was a simple matter of re-ordering the letters to make: MERRY XMAS!

Thanks to Chris Shiflett for the fun diversion. Though, it looks like I missed submitting the correct answer by only a few minutes (congrats Cogocogo) … it was still an enjoyable brain exercise.

Found an Old Song I Co-wrote

I used to have a site full of my old bands’ music, but that site went down and all those songs got trashed. I have them all backed-up on disc somewhere, but haven’t had a chance to go through all the stuff we have in boxes.  Anyway, I found this mp3 in one of my archives and I’m posting it here for the time-being. Wow, it’s almost 10 years old:

Smooth Like Roy’s You Know I Would

NewIceEnemy – GirlTalk inspired mash

After seeing SO many tweets about how great and awesome and wonderful the new GirlTalk “album” is, I decided to do a quick mashup on my own. It seems the formula is:  1) find an instrumental hook from an 80s pop song, 2)get some rap acapellas,  3) grab a vocal hook from some other ironically cheesy song, 4) mix them together.  In that vein, here’s my New Kids on the Block, Vanilla Ice, Public Enemy mashup:

NewIceEnemy

Idea for November 2nd

    Driving home tonight, I thought about how Facebook has really tapped into something that regular people are drawn to.  Namely, to stay in contact with friends, meet new friends, and play games with those friends. With updates and pictures and videos, you can be a part of people’s lives even if they’re miles away.  It’s pretty powerful stuff.

    That got me thinking, “What else drives people?”, and what kind of site could be built to tap into that drive.  I realized, thinking about the rise of “reality” TV and American Idol over the past decade, that many people (mostly younger, it seems) have a notion that they have a god-given right to be famous. It seems to generally be an American notion, but shows like X-factor and Big Brother in the UK seem to suggest the trend is spreading. And then looking at people on The Hills or the Kardashians or Paris Hilton, over the past 5 years, people are becoming super famous without having any discernible talent.

    So how can you tap into that desire for fame, using the web? I haven’t researched it, and someone may have already tried it, but maybe there’s a way to have people upload videos, music, stories, poems, whatever… then other users give them an up-or-down Digg-like vote.   Then once a month or so, the winners are highlighted on the front page…  given a prize… I don’t know.

    I think the main section of the site would be a timed contest. When you upload something, it goes into the current contest, like a month long. Once the contest is over, the winner(s) have their entries removed from further contests.  The winners would also be ineligible from winning again for a period of time… 6 months or a year. Non-winners have all their votes reset, but each entry can be eligible for up to 6 months of contests… after which, the entry is ineligible from further contests.

    There should also be another section that works as like an archive.  So all unique votes are tallied, and it displays the most popular entries from all time. Maybe people could have entries that don’t go into the contest… but are just submitted for the general votes.  So past winners could still upload content and be voted on for the overall.

    Another thought, before you can vote on other’s, you have to upload something.  That way, you don’t just have trolls, but people actually participating in the site.  There should also be a mechanism for weeding out people that upload crap just to be able to vote… maybe a “spam” button? Of course, there’s a potential for that being abused.

    It sounds a bit YouTube-y… but with more than just videos, and with a contest element instead of just Views.

Voting: If you just had links to entries where you could vote, there’s a potential for some entries to get many more views and votes. This may not be a bad thing, and bring that organic, viral quality like YouTube.  On the other hand, to be somewhat fair, there might need to be a Hot-or-Not voting system that randomly selects entries for you to vote on. I think there should also be categories for the winners… so videos and written entries would have different winners.  Though, there should also be an Overall winner who gets the big prize.

    Really, I think the key to the success of this site would be: 1) It needs to be super simple to register and add content. VERY low barrier to entry. 2) There should be a good number of users who add content, helped by #1, and 3) the prizes need to be nice, also feeding into #2.

Prizes: To start with, the main prize should be at least $2500.  Ideally, it should be around $10k… because THAT is “real” money. Individual category prizes could start at $500, but should eventually get up to the $2500 range. Actually, as I think about it, it would be best to start at $10K… start with a BANG and reach critical mass as soon as possible. Logistically though, that’s a bit impractical unless a huge sponsor is involved from the beginning.  However, there would still need to be at least $20K invested from the beginning to cover a few months, even if we went with the lower prizes.

Income: Pretty much this would all be ad revenue. One or two big sponsors? Use pre/post rolls or lower-thirds on the videos, text ads, overall site branding.  I think target demo for the site is 13-25 year olds, with outliers up to 40… very appealing to advertisers.

    That’s all I got… if anyone decides to pursue the idea, let me know.

Rallies and Sanity

I spent Saturday, mid-day, watching Jon Stewart’s Rally To Restore Sanity on Comedy Central’s amazingly clear live stream. I had considered heading downtown for the Restore Sanity Austin rally, but instead decided to avoid the hassles and actually watch a good quality version of the DC event.

Most of my thoughts about the Rally are mirrored by much better writers, but here’s a brief  rundown:

  1. The Roots/John Legend intro was okay, but much of the music was so down-beat… it may not have been the best the instill excitement and/or fun.
  2. The bits with the other Daily Show correspondents should’ve either been expanded, so they could do solo/team bits in the crowd… or cut completely.  The back-and-forth they tried was a bit of a train-wreck.
  3. Yusef(Cat Stevens)/Ozzy was a fun bit and a highlight.  My one, personal, complaint was I would’ve liked to hear “Peace Train” in its entirety.
  4. The Colbert “media/pundit/fear” video montage was great.  There really should’ve more of that.  If anything, their efforts to be non-political through most of the rally really hindered things.
  5. Stewart’s closing speech was near perfect.

What’s most interesting about the rally was the post-rally analysis. Obviously, people  in the media are going to push back at being criticized, like David Carr:

His barrage against the news media Saturday stemmed from the fact that, on this day, attacking the message would have been bad manners, so he stuck with the messengers.

Of course, as others have said, he really misses the point.  The “message” isn’t the issue here. All American’s hold different beliefs and different “messages”, but it’s the messenger that tries to pit these people against each other, for the sake of ratings.

Similarly, George Will on This Week misses the point:

We have two parties for a reason. We have different political sensibilities. People tend to cluster. We call them parties, and we have arguments, and that’s called politics.

He is conflating “sanity” with “not having an opinion”. Stewart was actually pretty clear that this was NOT his point.  Huffington tried to clarify, and brought up the quote from Stewart, “we can have animus and not be enemies”.  The idea is that we can have totally different beliefs, and we can fight for those beliefs… but we don’t insult those with differing beliefs or call them Hitler. Or Socialists. Or Communists. Or Nazis. Or Idiots.

Sadly, I don’t think the rally will have much effect on the 24-hour News Channels.  They have sunk deep into the “reality TV” notion that conflict = ratings.  And they’re right.  Maybe, though, the rally will have enough effect that people start turning off CNN, MSNBC, and FOX, especially for shows that encourage arguments  for argument’s sake.