Giter VIP home page Giter VIP logo

microblog's Introduction

Mini Microblog

A simple PHP app that stores Twitter-like status updates in a sqlite database. It also generates a JSON feed, that can be used as a source for the Micro.Blog service. It is aimed at people who would like to host their own micro.blog, but want to avoid using Wordpress for it.

The app supports crossposting to Bluesky and also acts as a member of the Fediverse, in that eg. Mastodon/ActivityPub users can follow and like status updates.

a screenshot of the microblog app

There is a timeline view of your own posts, as well as a simple 'compose post' page behind a login form. Right now, only a unique ID, the post content and creation timestamp, edit time and delete status are saved for each entry, so this is only suitable for one user.

The entire design is in a directory inside a /css/ (eg. microblog/microblog.css) and can be modified easily. The site HTML is pretty straightforward and should be easy to style from the /templates/ and /snippets/ directories.

ATOM and JSON feeds are provided and rerendered as static files when posting.

If the PHP version on the server supports it, an XML-RPC interface is provided to enable posting from external apps, such as Marsedit. Please set an app_token in config.php as secret to use with your username. If you don't set one, you have to use your login password to authenticate. You can use the metaWeblog API, that is discovered automatically, or add a Micro.Blog account and point it to your site. As a bonus, you can schedule posts this way, if you set the creation date in the future ;)

The app requires at least PHP 7.2 and was tested on 8.1. It needs mbstring, curl, sqlite and openssl modules.

Installation

  • copy (or clone) the files to a directory on your webserver
  • have them accessible from the domain (or subdomain) root /
  • for Apache: edit .htaccess and set RewriteBase to a path matching your installation directory
  • for nginx: have a rule similar to try_files $uri $uri/ /index.php?$args; for the microblog-location
  • open the website in the browser, it should take you to the site settings page and prompt you to enter a password, or set up a passkey

Optional

  • modify the theme file microblog.css
  • do more configuration under /settings, eg. fill in ActivityPub and Bluesky info
  • set an app_token to use with XML-RPC
  • setup a Passkey to log in with

To Do

  • test whether the ping function actually works
  • improve html rendering (?)
  • unify autolink regexes of atprotocol.php and autolink.php
  • support file attachments (started! can attach images to posts and remove them)
  • see issues

Support my work

The app is provided for free, but if you'd like to support what I do, please consider tipping or sponsoring โ€“ it is greatly appreciated. Can't promise it'll buy you software support, but if you send a reasonable PR, I'm happy to accept improvements to the app. Links are under GitHub's official sponsor button.

microblog's People

Contributors

axodys avatar gerriet avatar jaquer avatar oelna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microblog's Issues

License?

Does this project have a license? If not, you could pick:

  • Apache 2.0 or MIT -- very permissive, only requiring credit
  • GPLv3 or AGPLv3 -- requires code to be shared if they distribute ("convey") it. Additionally, AGPL counts running it on your server as distribution, so you must share code.

You can add the licenses just by putting them in a file called LICENSE or COPYING. Additionally, you should add something in the README (and optionally all source files), depending on the license.

For Apache 2.0:

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

For the GPLv3:

Copyright (C) <year>  <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For the AGPLv3:

Copyright (C) <year>  <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For MIT, it's short enough that for such a notice you can just use the full text of the license.

MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[not an issue] Youtube links to Embed player

Here's a small function that will convert youtube links in your post to embed youtube player. I was too lazy to modify the autolink function because it's not documented properly. So I just wrapped this function with it inside the template. Feel free to add it to the next update @oelna

function youtube($string,$autoplay=0,$width=480,$height=390)
{
    preg_match('#(?:https://)?(?:www\.)?(?:youtube\.com/(?:v/|watch\?v=)|youtu\.be/)([\w-]+)(?:\S+)?#', $string, $match);
    if(isset($match[1])) {
    $embed =  '<iframe title="YouTube video player" width="100%" height="350" src="http://www.youtube.com/embed/'.$match[1].'?autoplay=$autoplay" frameborder="0" allowfullscreen></iframe>';
    return str_replace($match[0], $embed, $string);
    }
    else return $string;
}

Check my fork!

Hey! I had been looking for ultra-minimal micro-blogging software for quite some time, and today I came across Microblog, which seemed simple enough for my needs. My goal is to create a micro-blogging service for myself, where I can post only to myself, as I need a place to vent and express myself privately.

However, in order for Microblog to be useful to me, it required some taming. I removed ActivityPub and Twitter support, added a config parameter for the database path, fixed localhost deployments (for testing), and fixed other small things that were very broken (how could everything in lib/ even load with incorrect paths in the default config!?)

Here's the repository of my fork: https://git.avalos.me/microblog

Feel free to take what you wish from my fork.

Autolink - beware!

If you want to embed content into posts using a URL (videos, photos, etc) autolink will mess it up and it won't work.
There's reasons for it being a feature, this more of a tip for others, as I spent some time trying to figure out why I couldn't embed media.

The function autolink is referenced here and here.

To disable it :

autolink($post['post_content']) -> $post['post_content']

Localhost installation

  1. Installed on localhost (simple copy files across).
  2. Updated Config with subdir with files.
  3. Run and creates DB, but when you hit NEW tries and fails with:

Not Found
The requested URL /microblog/mb/login was not found on this server.
Apache/2.4.23 (Win64) PHP/5.6.25 Server at localhost Port 80

I can see the code looks at path(0) for 'login' - but path(0) is not login..

Any help appreciated.

Can't manage to run on Localhost (Mamp)

@oelna I'm getting too many redirects error.

DB file was automatically created so at least it ran through some of it.

.htaccess looks like this. I've only added RewriteCond %{SERVER_PORT} 8888. because the default url for mamp is localhost:8888 but the error persists even without my line.

AddCharset UTF-8 .xml
AddCharset UTF-8 .json

AddType application/atom+xml .xml
AddType application/json .json

<Files ~ "\.db$">
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
</Files>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /microblog

# friendly URLs
RewriteRule ^feed/json/?$ feed/feed.json [L]
RewriteRule ^feed/atom/?$ feed/feed.xml [L]

RewriteCond %{SERVER_PORT} 8888
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>

Error log says:
RewriteCond: bad flag delimiters

Any ideas?

Atom vs RSS 2.0 in a Microblog Context

One thing that's been weighing on me for a while since discovering this project is that you chose to implement the xml feed with Atom rather than RSS 2.0. This surprised me because Atom specifies that every post must have a title and a defining feature of RSS and the microblog effort is that titles are optional. One of the things I'm thinking about working on next is getting the xml feed closer to parity with the json feed with image attachments support, but my inclination is to do the work in a new rebuild_rss_feed() function and leave the Atom support alone. Does that sound reasonable to you? An RSS implementation could also allow for micro podcast support in the future as well if we just passed entries with audio attachments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.