Changing Size of Photos Uploaded to Nodebb

Original link

Why nodebb?
I don't know

Nodebb official GitHub

Nodebb Chinese Forum

Nodebb official document

Nodebb Chinese document

install

The mode hither is to install and deploy docker(https://hub.docker.com/r/node…
There is no need to consider the environment configuration, just there are also some disadvantages
For instance, the modification of files becomes troublesome

Beneath is yaml of nodebb paradigm

            cumt:   paradigm: index.docker.io/nodebb/docker:v1.9.3   privileged: false   restart: ever   ports:   - 4567:4567   volumes:   -/ BBS /: / usr / SRC / APP / config ᦇ for the convenience of modifying files, a folder is added to facilitate file substitution with the host computer   -/ BBS / public / uploads / usr / SRC / APP / public / uploads          

At the same time, it is recommended to utilise China's container management platform for docker direction. The paradigm will directly pull the paradigm copied in Red china
The studio is currently usinghttps://www.daocloud.io/

After pulling the nodebb image and generating the container, pull a mongodb epitome equally the database container
For the convenience of maintenance, you can use a split container to direct pull the new version image in the future nodebb forum upgrade
When installing the new version, simply fill in the intranet address of the database container~

Later the mongodb container is successfully generated, we need to starting time enter the container to create the database name and the corresponding user password of the database
There are likewise official introductions

Here is the yaml of Mongo prototype. We can update the information to the host synchronously through the information volume

            mongodb:   image: library/mongo:3.4.fifteen   privileged: fake   restart: ever   ports:   - 27017:27017   volumes:   - /var/lib/docker/volumes/mongoconfig/_data:/information/configdb   - /var/lib/docker/volumes/mongodata/_data:/data/db          

Generally, domestic servers will exist configured with security groups. For convenience, you can temporarily open the mongodb container's external network port
In the local remote connection configuration, a Windows visualization tool is recommended hereRobo 3T

Then we set the domain name nosotros demand through nginx proxy~

After installation, you lot tin can configure your ain Bulletin board system. This way will salvage usa a lot of problem in environment configuration

Possible issues

  • The forum always shows disconnect

At this point, you lot need to modify the container config.json The URL inside is your custom domain proper noun

Version upgrade

Nodebb is non easy to upgrade. Co-ordinate to the operation of official documents, we need to get-go back up the database and upload files
But we apply a few words of docker to avert these bug
Then all we have to do is update the docker prototype, regenerate the container, and configure the corresponding database

  • It should exist noted that we need to disable all plug-ins after generating a new container to prevent the nodebb organisation from crashing straight
            ./nodebb reset -a          

Database maintenance and backup

Information technology is very important to dorsum upward the database regularly and migrate to other machinesDatabase backup

Because we employ the docker container, the backup command needs to connect to our corresponding intranet address

            Mongodump - H 172.22.0.12:27017 - U user name - P password -- authenticationdatabase = database name - D database proper noun          
  • Nosotros demand to note that if the script executed regularly is on the host, nosotros demand to install Mongo on the host to support the mongodump command
  • At the same time, the successful output statement of the scheduled backup script can not correctly reflect whether the backup is successful

We'd better check information technology regularly

If you want to recover the database file, nosotros tin can upload it to the new mongodb external information volume through our saved backup file
For example:

            Put the backup file in / var / lib / docker / volumes / mongodata of the host computer/_ data Open / information / DB directly in container Later decompression (tar - zxvf) xxx.tar.gz ) function mongorestore -u nodebb -p yourpassword --authenticationDatabase=nodebb -d nodebb --drib dump/nodebb that will exercise          

Discuz! Information migration to nodebb

The old forum database is mysql, which is totally unlike in database type, and it is impossible to have the same database field
But the nature of the forum makes their information fields the aforementioned. Nosotros merely need to filter the data we need, and then import the data nosotros desire to employ through the nodebb interface plug-in
In fact, this process is not technically difficult, only rather complicated and troublesome
First of all, we need to exist familiar with DZ and nodebb database fieldsDZ database dictionary

Filtering for users

We all know that the strange key of MySQL database is very convenient for united states of america to join tables or associated queries. In this manner, we can form JSON with the user information we need
Post to mongodb through nodebb interface (if you don't use API to import to Mongo straight, nosotros accept to combine Mongo fields ourselves)

Because nodebb API user creation merely supports user name and password, and postal service of mailbox, nosotros tin can record the user uid after successful cosmos, and then update the user information by updating the user information

About the user's Avatar, forum and other CMS generally have their own user avatar file naming rules
For DZ forum to get their own avatar code is every bit follows, we can get the path of the avatar folder by imitating the procedure

            part get_avatar($uid, $size = 'eye', $blazon = '') {     $size = in_array($size, array('big', 'heart', 'small')) ? $size : 'centre';     $uid = abs(intval($uid));     $uid = sprintf("%09d", $uid);     $dir1 = substr($uid, 0, three);     $dir2 = substr($uid, 3, 2);     $dir3 = substr($uid, 5, 2);     $typeadd = $type == 'real' ? '_real' : '';     return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg"; }  =============================================== #Python faux process def get_avatar(uid):     uid = str(abs(int(uid)))     uid_length = len(uid)     if uid_length < nine:         uid = '0'*(ix-uid_length)+uid     dir1 = uid[0:3]     dir2 = uid[3:5]     dir3 = uid[5:7]     dir4 = uid[7:9]     old_avatar = os.path.join(         basedir, 'avatar/'+dir1+'/'+dir2+'/'+dir3+'/'+dir4+'_avatar_middle.jpg')     return old_avatar  ...  if avatarstatus != 0:     old_avatar = get_avatar(uid)     new_avatar_address = '/assets/uploads/profile/%a-profileavatar.jpg' % adduser_uid     new_avatar = os.path.join(basedir, 'profile/%a-profileavatar.jpg' % adduser_uid)     shutil.copy(old_avatar, new_avatar)     update_data["picture"] = new_avatar_address     update_data["uploadedpicture"] = new_avatar_address          

Migration of Posts and replies

The theory is the same every bit above
We need to study the DZ database dictionary, such as this lexicon
Nosotros combine the mongodb lexicon we need according to the corresponding information fields
We need to annotation that subsequently the combination of this table segment, we also need to update the corresponding post data
Update the post publishing time and the author (in my script, merely the author of the post is updated, but the post publishing field is not updated, so the user does not record the number of Posts published, but the author of the post details page is displayed correctly)

Nodebb build, maintenance, Discuz! Data migration to Mongo

  • If an error is reported in importing Htmlparser, you can refer to the following file to update information technology to the corresponding lib / site packages folder in PythonHtmlparser error file reference
  • If requests fail, add time.sleep Reduce manual frequency
  • DZ is the Southward-level timestamp, and nodebb is the 13 chip millisecond level_ dateline = int(round(reply_ dateline*1000))

Migration script complete office (for reference)

fraziertherints43.blogspot.com

Source: https://developpaper.com/nodebb-build-maintenance-discuz-data-migration-to-mongo/

0 Response to "Changing Size of Photos Uploaded to Nodebb"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel