Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving images to v1e.com #421

Closed
jeffeb3 opened this issue Jan 24, 2023 · 5 comments
Closed

Moving images to v1e.com #421

jeffeb3 opened this issue Jan 24, 2023 · 5 comments

Comments

@jeffeb3
Copy link
Collaborator

jeffeb3 commented Jan 24, 2023

Forum for reference: https://forum.v1e.com/t/website-refresh/34933/90?u=jeffeb3

We have a bunch of images linked in the form:

tools/milling-basics.md:227:![!pic](https://www.v1engineering.com/wp-content/uploads/2018/06/start.jpg){: loading=lazy width="400"}

We need to move those to the new server (at the new URL). The docs should point to something at the new v1e.com site for these images.

I'll use this space to document the steps we're taking, and reference back to this for the final PR.

@jeffeb3
Copy link
Collaborator Author

jeffeb3 commented Jan 24, 2023

I found the list of images with this bash command:

grep -rn wp-content > v1_images.txt

That created a list of 580 lines with images linked from "wp-content". On closer inspection, those all look like valid images from the v1engineering website:

v1_images.txt

@jeffeb3
Copy link
Collaborator Author

jeffeb3 commented Jan 24, 2023

I created a python script to parse that list of images and download each image to a similar location on my local machine:

#!/usr/bin/python3

import os.path
import pathlib
import urllib.request

outdir='img/'

with open('v1_images.txt', 'r') as links:
    for line in links:
        # Find where the word "uploads/" ends
        upload_char = line.find('uploads')+8

        # Grab the text after that, until we reach a double quote or a close parenthesis
        filename = line[upload_char:].strip().split(')')[0].split('"')[0].strip()

        # Use os.path to find the folder name
        foldername = os.path.dirname(filename)

        # Get the original URL by getting everything until a close parenthesis, and then everything
        # back to the open parenthesis, and then cut off anything after the double quote.
        original_url = line.split(')')[0].split('(')[-1].split('"')[0].strip()

        # Make the directory (should be OS independent. It works in Linux)
        pathlib.Path(outdir+foldername).mkdir(parents=True, exist_ok=True)

        # Download the url to the output folder
        print('downloading: ', url)
        urllib.request.urlretrieve(url, filename=outdir+filename)

The result is a folder img with the images downloaded. I zipped these images up, and I will email them to you, @V1EngineeringInc.

@jeffeb3
Copy link
Collaborator Author

jeffeb3 commented Jan 24, 2023

This is what I think the next steps are:

  • You can upload the images from the zip file I am sending you somewhere on v1e.com. Ideally, in the same or similar folder structure
  • There will be some new url. Instead of https://www.v1engineering.com/wp-content/uploads/2018/06/start.jpg, it will be https://v1e.com/media/2018/06/start.jpg or something like that.
  • I can write a sed script to replace all the instances of www.v1engineering.com/wp-content/uploads/ with v1e.com/media/ and run it in the local copy of the docs. That should change all the markdown files at once.
  • I will commit and make a PR. The PR merging should be fine, as long as all the files are in the right place, because they followed the same pattern.

@jeffeb3
Copy link
Collaborator Author

jeffeb3 commented Jan 28, 2023

Fixed in #424 by merging them into this repo.

@jeffeb3 jeffeb3 closed this as completed Jan 28, 2023
@V1EngineeringInc
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants